E4176#
Compiler diagnostic name: invalid_lexmatch_target.
无效的 lexmatch 目标。
lexmatch 作用于文本视图。目标表达式的类型必须可以被正则模式匹配,例如 String 或 StringView,而不能是数值、布尔值或其他无关类型。
错误示例#
///|
pub fn match_number(n : Int) -> Unit {
lexmatch n with longest {
_ => ()
}
}
目标是 Int,不能被 lexmatch 消费。
修改建议#
匹配字符串类值,或先转换输入再进行匹配。新代码请使用 lexscan,而不是已弃用的最长匹配 lexmatch 形式。
///|
pub fn match_text(text : String) -> Unit {
lexscan text with longest {
_ => ()
}
}