E4007#
Enum variants without payloads are considered as singleton values. MoonBit does not allow such constructors to be called as functions.
错误示例#
enum Status {
Done
Pending
}
fn main {
let status = Done() // Error: constructor without payload cannot be called with ()
}
建议#
Remove the function calling syntax from the constructor:
// ...
fn main {
let status = Done
}
If you really need the constructor to construct values, explicitly use Unit
as
its argument
enum Status {
Done(Unit)
Pending
}
fn main {
let status = Done(())
}