Home / Docs / Diagnostics
U2002: Unknown or ill-formed type
Release v0.4.0
U2002 reports a written type that is unknown or ill-formed.
Why Una rejects it
A written type names a built-in type, a kind or a type parameter (spec/03). U2002 reports:
- a name that denotes something else, such as a variant or a capability;
- range sugar on a type other than
Int; - a
failsclause that names anything but a sum kind without type parameters; - an alias defined in terms of itself;
- a record or sum kind that contains itself other than through
ListorOptionfields, since every value must be finite (spec/03 §2 rule 5).
A refined kind or a range written as a type argument, as List[Pos], is U2002 in editions 0.1 and 0.2 (ADR 0040). Edition 0.3 accepts it and proves the refinement of every element where values are built (ADR 0103).
How to fix it
For a recursive field, the diagnostic carries an edit that makes the field optional.
The repair at a glance
diff
module demo
pub kind Node
value: Int
- next: Node
+ next: Option[Node]Failing example
una
module demo
pub kind Node
value: Int
next: NodeFixed example
una
module demo
pub kind Node
value: Int
next: Option[Node]