E4007

E4007#

Enum variants without payloads are considered as singleton values. MoonBit does not allow such constructors to be called as functions.

Erroneous example#

enum Status {
  Done
  Pending
}

fn main {
  let status = Done() // Error: constructor without payload cannot be called with ()
}

Suggestion#

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(())
}