# E0022

Warning name: `ambiguous_block`

Ambiguous block expression. In MoonBit, the expression `{ value }` is ambiguous
because it could be interpreted as a block expression or a struct literal. For
now, we treat it as a struct literal, but writing such expressions is
discouraged.

## Erroneous example

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

## Suggestion

If you want to construct a struct using the struct literal, you can add a comma
to the end of the struct literal. Or you can call formatter on this buffer to
have the comma added automatically.

```{literalinclude} /sources/error_codes/0022_fixed/example_0.mbt
:language: moonbit
:start-after: start example
:prepend: "///|\nfn main {"
```

If you are using it as a block expression, please remove the braces as it has
only one expression and is equivalent to the expression `value`:

```{literalinclude} /sources/error_codes/0022_fixed/example_1.mbt
:language: moonbit
:start-after: start example
:prepend: "///|\nfn main {"
```
