E4176

E4176#

Compiler diagnostic name: invalid_lexmatch_target.

此诊断码曾用于表示无效的 lexmatch 目标,当前编译器已不再发出该诊断。当前对应的诊断是 E4222

lexmatch 作用于文本视图。目标表达式的类型必须可以被正则模式匹配,例如 StringStringView,而不能是数值、布尔值或其他无关类型。

错误示例#

///|
pub fn match_number(n : Int) -> Unit {
  lexmatch n with longest {
    _ => ()
  }
}

目标是 Int,不能被 lexmatch 消费。

修改建议#

请匹配 StringStringView,或者在匹配前转换输入。

///|
pub fn match_text(text : String) -> Unit {
  lexmatch text with longest {
    _ => ()
  }
}