E4180#
Compiler diagnostic name: unsupported_match_strategy.
Unsupported lexmatch match strategy.
lexmatch only supports the default first-match strategy and the explicit
longest strategy. Other strategy names are rejected.
Warning
lexmatch is deprecated for new code. Prefer regex match expressions such as
value =~ re"..." unless you specifically need legacy lexer-style behavior.
Erroneous example#
The following example asks for an unsupported shortest strategy:
///|
fn classify(input : String) -> String {
lexmatch input with shortest {
"if" => "keyword"
_ => "identifier"
}
}
///|
test {
ignore(classify)
}
MoonBit will report an error.
Suggestion#
Use one of the supported strategies, or rewrite the code with a regex match expression when first-match behavior is enough: