E4200

E4200#

Compiler diagnostic name: struct_constr_incorrect_return_type.

A struct constructor must return the struct type itself. If the constructor signature returns another type, the declaration cannot be used as that struct’s constructor.

Erroneous example#

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

///|
fn Point::Point(_: Int) -> String {
  ""
}

Suggestion#

Make the constructor return the struct type and implement the matching Type::Type function.

///|
priv struct  {
   : 
}

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

///|
test {
  let  = (1)
  (., ="1")
}