E4144

E4144#

This is a constant, not a constructor, it cannot be applied to arguments.

This error occurs when you try to use a constant as a constructor in pattern. One possible reason for this error is that you have a constant with the same name as an external constructor, and in such case you need to either use qualified name or type annotations to disambiguate.

错误示例#

pub const Value : Int = 1

fn main {
  match { ... } {
    Value(_) => println("Value")
  //^~~~~
  // Error: 'Value' is a constant, not a constructor, it cannot be applied to arguments.
  }
}

建议#

If you want to match against the constant, you can remove the playload from the pattern.

fn main {
  match { ... } {
    Value => println("Value")
  }
}

Or if the constant has the same name as an external constructor, you can use qualified name or type annotations to disambiguate.

fn main {
  match { ... } {
    @a.Value(_) => println("Value")
  }
}