E3009

E3009#

A record pattern cannot contain only ... Use the wildcard pattern _ instead.

Erroneous example#

///|
struct Point {
  x : Int
  y : Int
}

///|
fn process_point(p : Point) -> Unit {
  match p {
    { .. } => println("Got a point")
    //^~~~~~
    // Error: Struct pattern cannot contain only `..`, use wildcard pattern `_` instead.
  }
}

Suggestion#

Use the wildcard pattern _ instead of { .. }:

///|
pub(all) struct Point {
  x : Int
  y : Int
}

///|
fn process_point(p : Point) -> Unit {
  match p {
    _ => println("Got a point")
  }
}

///|
test {
  let p : Point = { x: 0, y: 1 }
  process_point(p)
  process_y_axis(p)
}

You can also use { .. } along with other fields if you want to match specific fields:

///|
fn process_y_axis(p : Point) -> Unit {
  match p {
    { x: 0, .. } => println("Point on y-axis")
    _ => println("Other point")
  }
}