# 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

```{literalinclude} /sources/error_codes/4171_error/top.mbt
:language: moonbit
```

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](E4224.md).

```{literalinclude} /sources/error_codes/4171_fixed/top.mbt
:language: moonbit
```
