E4173

E4173#

Compiler diagnostic name: invalid_value_type_attr.

Invalid #valtype declaration.

#valtype asks the compiler to represent a type as a value type. Value-type fields must be immutable, so a declaration with a mutable field is rejected.

Erroneous example#

#valtype
struct Counter {
  mut value : Int
}

The field value is mutable.

Suggestion#

Make the field immutable, or remove #valtype if the type needs in-place mutation.

#valtype
struct Point {
  x : Int
  y : Int
}