# E4042

Compiler diagnostic name: `invalid_stub_type`.

Invalid stub type.

When defining an FFI function, each parameter and return type must be a valid
stub type that can be represented natively by the selected backend.

For example, `FixedArray[T]` is not a valid stub type for the Wasm GC backend.

## Erroneous example

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

## Suggestion

The way to pass non-native types through the FFI interface depends on both the
backend of the MoonBit compiler and the runtime you are using. Use a native
stub type directly, or pass a handle/index and manage the compound value on the
host side.

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