# E0013

Warning name: `unresolved_type_variable`

The type of this expression contains unresolved type variables.

This error occurs when the compiler encounters a type that contains type
variables which cannot be determined from the context. Type variables are
placeholders for types that should be inferred by the compiler.

Common cases where this happens:

1. Writing local functions without explicit type annotations
2. Creating empty collections (Arrays, Options) without specifying their element
   type

When the compiler cannot resolve these type variables, it defaults them to
`Unit` type, which may not be what you intended.

## Erroneous example

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

## Suggestion

To fix this warning, you can:

- Add type annotations to local function parameters. For example,

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

- Explicitly specify the type of the variable or the collection element type.

   ```{literalinclude} /sources/error_codes/0013_fixed/example_1.mbt
   :language: moonbit
   ```

   Or equivalently, add annotations on the collection creation.

   ```{literalinclude} /sources/error_codes/0013_fixed/example_2.mbt
   :language: moonbit
   ```

- Provide enough context through usage.

   ```{literalinclude} /sources/error_codes/0013_fixed/example_3.mbt
   :language: moonbit
   ```
