# E4186

Compiler diagnostic name: `guard_not_supported_in_longest_match_strategy`.

Guards are not supported in longest-match `lexmatch` cases.

The longest-match strategy decides which regex case wins before running the case
body. Case guards would make that decision depend on arbitrary expressions, so
they are rejected for `lexmatch ... with longest`.

## Erroneous example

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

The first case has an `if` guard.

## Suggestion

Move the condition into the case body so the longest-match decision depends only
on the regex patterns.

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