E0076#
Warning name: lexmatch_first_match
Using lexmatch with first-match semantics is deprecated.
This warning is emitted for lexmatch expressions that use the default
first-match strategy, including lexmatch ... with first. Prefer regex match
expressions for ordinary regex checks in new code.
Erroneous example#
///|
fn classify(input : String) -> String {
lexmatch input {
"if" => "keyword"
_ => "other"
}
}
///|
test {
ignore(classify)
}
Suggestion#
Rewrite first-match lexmatch code with a regex match expression when possible.
If you specifically need lexer-style longest-match behavior, make that explicit
with lexmatch ... with longest.
///|
fn classify(input : String) -> String {
if input =~ re"^if$" {
"keyword"
} else {
"other"
}
}
///|
test {
ignore(classify)
}