# E4173

Compiler diagnostic name: `invalid_value_type_attr`.

Invalid `#valtype` declaration.

`#valtype` asks the compiler to represent a type as a value type. Not every type
shape can be represented this way. The compiler rejects declarations that would
require boxed or runtime-object storage, such as a type parameter field, an
object field, a mutable field, too many fields, or a nested value type field.

## Erroneous example

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

The field `value` has type `T`, a type parameter. A value type must have a
concrete supported layout, so this generic field is rejected.

## Suggestion

Use concrete scalar fields for the value type, or remove `#valtype` if the type
needs a generic or boxed layout.

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