E4176

E4176#

Compiler diagnostic name: invalid_lexmatch_target.

This diagnostic code was used for an invalid lexmatch target and is not emitted by the current compiler. The current diagnostic is E4222.

lexmatch works on textual views. The target expression must have a type that can be matched by regex patterns, such as String or StringView, instead of a numeric, boolean, or other unrelated type.

Erroneous example#

///|
pub fn match_number(n : Int) -> Unit {
  lexmatch n with longest {
    _ => ()
  }
}

The target is an Int, which cannot be consumed by lexmatch.

Suggestion#

Match a String or StringView, or convert the input before matching.

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