E4184#

Compiler diagnostic name: start_rest_binder_is_not_supported_in_longest_match_strategy.

この診断は以前の字句パターン構文における先頭の残余部分の束縛を説明するものであり、現在のコンパイラでは発生しません。現在対応する束縛エラーは E4220 です。

lexmatch ... with longest では各正規表現が入力の先頭から始まるため、before= は利用できません。

Erroneous example#

///|
pub fn match_text(text : String) -> Unit {
  lexmatch text with longest {
    (_, "abc", _) => ()
    _ => ()
  }
}

The first _ attempts to bind or skip input before the "abc" regex pattern.

Suggestion#

^ で先頭に固定した正規表現を使い、必要な場合だけ after= で接尾部分を束縛してください。

///|
pub fn match_text(text : String) -> Unit {
  lexmatch text with longest {
    (re"^abc", after=_) => ()
    _ => ()
  }
}