# E4186

Compiler diagnostic name: `guard_not_supported_in_longest_match_strategy`.

This diagnostic code was used for guards in longest-match lexical cases and is
not emitted by the current compiler. The current diagnostic is
[E4217](E4217.md).

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 selection depends only on the regex
patterns.

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