# E4227

Compiler diagnostic name: `cancel_not_allowed_in_context`.

A cancellable async function is called from an async context declared with
`nocancel`.

`nocancel` promises that cancellation cannot be introduced by the function.
Such a function may call synchronous functions and other `nocancel` async
functions, but not cancellable async functions.

## Erroneous example

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

## Suggestion

Remove `nocancel` from the caller when it needs to perform a cancellable
operation. If the callee genuinely cannot be cancelled, declare the callee
with `nocancel` as well.

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