E4144

E4144#

这是一个常量,不是构造函数,不能应用于参数。

当你尝试使用常量作为其他包中的构造函数的参数时,会发生此错误。可能的原因是你有一个与其他包中的构造函数同名的常量,在这种情况下,您需要使用限定名或类型注释来消除歧义。

错误示例#

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.
  }
}

建议#

如果要匹配常量,您可以从模式中删除负载。

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

或者,如果常量与其他包中的构造函数同名,您可以使用限定名或类型注释来消除歧义。

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