# E0091

Warning name: `unused_errdefer`

An `errdefer` statement cannot run because the rest of its body cannot raise an
error. Unlike `defer`, `errdefer` performs its cleanup only when control leaves
the body by raising an error.

## Erroneous example

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

The statements after `errdefer` complete normally, so its cleanup is unused.

## Suggestion

Remove the statement if no cleanup is needed. Use `defer` for cleanup that must
always run, or keep `errdefer` before an operation that can raise an error when
the cleanup is needed only on failure.

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