E4197

E4197#

Compiler diagnostic name: cannot_match_struct_constr.

A struct constructor is a function, not a pattern constructor. It can be called to create a value, but it cannot be used in a match pattern.

Erroneous example#

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

///|
fn Point::Point(x : Int) -> Point {
  { x, }
}

///|
fn read(point : Point) -> Int {
  match point {
    Point(x) => x
  }
}

///|
test {
  let _ = read(Point(1))
}

Suggestion#

Read the struct fields directly, or use another pattern that does not call the constructor function.

///|
priv struct  {
   : 
}

///|
fn ::( : ) ->  {
  { , }
}

///|
fn ( : ) ->  {
  .
}

///|
test {
  (((3)), ="3")
}