Home / Docs / Diagnostics
U2009: Missing or unknown field in constructor
Release v0.4.0
A record or variant constructor gives every field of the kind, labeled when there are two or more, in any order (spec/04 §3 rule 4); a constructor with fields must be applied to them, since constructors are not values (ADR 0024). U2009 reports a missing field, a label that names no field, a variant without fields called with parentheses, and a pattern that binds a field its variant does not have. The diagnostic suggests the closest field name when there is one.
The repair at a glance
diff
module demo
pub kind Point
x: Int
y: Int
- pub origin() -> Point = Point(x: 0)
+ pub origin() -> Point = Point(x: 0, y: 0)Failing example
una
module demo
pub kind Point
x: Int
y: Int
pub origin() -> Point = Point(x: 0)Fixed example
una
module demo
pub kind Point
x: Int
y: Int
pub origin() -> Point = Point(x: 0, y: 0)