E4176#
Compiler diagnostic name: invalid_lexmatch_target.
Invalid lexmatch target.
lexmatch works on textual views. The target expression must have a type that
can be matched by regex patterns, such as String or StringView, instead of a
numeric, boolean, or other unrelated type.
Erroneous example#
///|
pub fn match_number(n : Int) -> Unit {
lexmatch n with longest {
_ => ()
}
}
The target is an Int, which cannot be consumed by lexmatch.
Suggestion#
Match a string-like value, or convert the input before using lexmatch.
///|
pub fn match_text(text : String) -> Unit {
lexmatch text with longest {
_ => ()
}
}