E4182

E4182#

Compiler diagnostic name: regex_constant_ref_in_lex_is_not_supported.

This diagnostic described a restriction of an earlier lexical pattern form and is not emitted by the current compiler.

Current lexmatch and lexscan cases accept regex constant expressions, including named const values.

Erroneous example#

The following historical example uses the old pattern shape:

///|
const WORD = re"[A-Za-z]+"

///|
pub fn match_word(input : String) -> Unit {
  lexmatch input with longest {
    (WORD, _) => ()
    _ => ()
  }
}

Current code should use the regex constant as the case pattern instead.

Suggestion#

Use the regex constant directly as the case pattern:

///|
const WORD = re"^[A-Za-z]+$"

///|
pub fn match_word(input : String) -> Unit {
  lexmatch input with longest {
    WORD => ()
    _ => ()
  }
}