# E4175

Compiler diagnostic name: `as_not_trait_object`.

The right-hand side of `as` is not a trait object type.

MoonBit uses `as &Trait` to convert a value to a trait object. The target type
must therefore be a trait object type such as `&Show`, not an ordinary concrete
type, type parameter, or package type.

## Erroneous example

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

`Int` is a concrete type, not a trait object type, so it cannot be used on the
right-hand side of `as`.

## Suggestion

Use `as &Trait` when you want a trait object. If you only need a type
annotation, write the expected type as an annotation instead of using `as`.

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