# E4022

Compiler diagnostic name: `unbound_constant`.

Unbound regex constant.

Regex match expressions and legacy `lexmatch` patterns can refer to regex
constants. The constant must be declared and visible at the use site. If the
name cannot be resolved as a constant, MoonBit reports this error.

## Erroneous example

The following example refers to `WORD` without declaring it:

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

MoonBit will report an error.

## Suggestion

Declare the regex constant before using it, or use a regex literal directly:

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