E0076#
Warning name: lexmatch_first_match
This warning described an earlier experimental form of first-match lexmatch
and is not emitted by the current compiler.
Current lexmatch expressions use re"..." case patterns and may use the
default first-match strategy. For a single boolean check, a regex match
expression is usually more concise.
Erroneous example#
///|
fn classify(input : String) -> String {
lexmatch input {
"if" => "keyword"
_ => "other"
}
}
///|
test {
ignore(classify)
}
Suggestion#
Rewrite the old string-piece pattern syntax with re"..." cases, or use a
regex match expression when only a boolean result is needed.
///|
fn classify(input : String) -> String {
if input =~ re"^if$" {
"keyword"
} else {
"other"
}
}
///|
test {
ignore(classify)
}