E4199#
Compiler diagnostic name: struct_has_no_constr.
The call syntax Type(...) is available only for structs that declare a
constructor. A regular record-style struct can still be created with a record
literal, but it does not automatically get a constructor function with the
struct name.
Erroneous example#
///|
pub(all) struct Point {
x : Int
}
///|
test {
let _ : Point = Point(1)
}
Suggestion#
Use record construction, or declare and implement a constructor before calling the struct as a function.
///|
pub(all) struct Point {
x : Int
}
///|
fn make_point(x : Int) -> Point {
{ x, }
}
///|
test {
let point = make_point(1)
inspect(point.x, content="1")
}