E4222#
编译器诊断名称:invalid_lexscan_target。
无效的词法匹配目标。
lexmatch 接受内存中的 String 或 StringView。lexscan 旨在用于 @lexbuf.Lexbuf 或 @lexbuf.AsyncLexbuf。为兼容起见,它暂时也接受 String 和 StringView,但会发出弃用警告;这些输入请使用 lexmatch。数字或用户自定义的类词法缓冲区类型等其他值不能由这些表达式匹配。
错误示例#
///|
pub fn match_number(number : Int) -> Unit {
lexmatch number with longest {
_ => ()
}
}
建议#
请对字符串类型的值使用 lexmatch,或者为 lexscan 创建词法缓冲区。
///|
pub fn match_text(text : String) -> Unit {
lexmatch text with longest {
_ => ()
}
}