E4201#
Compiler diagnostic name: struct_constr_inconsistent_impl.
The implementation of a struct constructor must have the same parameter and
return types as the constructor declaration in the struct. A method with a
different signature is not an implementation of that constructor.
Erroneous example#
///|
priv struct Point {
x : Int
fn new(Int) -> Point
}
///|
fn Point::new(text : String) -> Point {
{ x: text.length() }
}
Suggestion#
Change either the constructor declaration or the Type::new implementation so
their signatures match.
///|
priv struct Point {
x : Int
fn new(Int) -> Point
}
///|
fn Point::new(x : Int) -> Point {
{ x, }
}
///|
test {
let point = Point(2)
inspect(point.x, content="2")
}