E3024#
Constructor function of struct must have name new.
This error happens when a constructor function declared inside a struct is
not named new. MoonBit treats new as the constructor entry point for the
struct.
Erroneous example#
pub struct S {
x : Int
fn constr(x : Int) -> S
}
fn S::constr(x : Int) -> S {
{ x, }
}
Suggestion#
Rename the constructor function to new:
pub struct S {
x : Int
fn new(x : Int) -> S
}
fn S::new(x : Int) -> S {
{ x, }
}
pub fn make(x : Int) -> S {
S::new(x)
}