E4171#
Compiler diagnostic name: last_regex_case_must_be_catchall.
lexmatch または lexscan 式のキャッチオールケースは、最後のケースでなければなりません。
キャッチオール分岐に到達すると、それ以降の正規表現ケースは選択されません。
Erroneous example#
///|
pub fn match_text(text : String) -> Unit {
lexmatch text with longest {
_ => ()
re"^abc$" => ()
}
}
_ 分岐が別の正規表現ケースより前にあります。
Suggestion#
キャッチオール分岐を最後に移動してください。式にキャッチオールケース自体がない場合は、E4224 を参照してください。
///|
pub fn match_text(text : String) -> Unit {
lexmatch text with longest {
re"^abc$" => ()
_ => ()
}
}