E4171#
Compiler diagnostic name: last_regex_case_must_be_catchall.
The catch-all case in a lexmatch or lexscan expression must be the last
case.
Once a catch-all branch is reached, later regex cases can never be selected.
Erroneous example#
///|
pub fn match_text(text : String) -> Unit {
lexmatch text with longest {
_ => ()
re"^abc$" => ()
}
}
The _ branch appears before another regex case.
Suggestion#
Move the catch-all branch to the end. If the expression has no catch-all case at all, see E4224.
///|
pub fn match_text(text : String) -> Unit {
lexmatch text with longest {
re"^abc$" => ()
_ => ()
}
}