Skip to content
ZOLO / TE161 Type · error

contextual construction requires an exact nominal struct type

Compiler diagnostic TE161: contextual construction requires an exact nominal struct type.

.{ ... } requires an expected named struct. An annotation, parameter or return type can provide that context:

struct Point { x: int, y: int }
let point: Point = .{ x: 1, y: 2 }

Without that context, use the explicit construction:

let point = Point { x: 1, y: 2 }

A map, unresolved type variable, optional or union does not identify one construction target. The compiler never guesses from field names or the set of declarations in scope. The editor offers an editable type-name placeholder replacing the dot.

Once the target is known, ordinary field diagnostics report duplicate, missing, unknown, private or incompatible fields. Those errors are not TE161.

Without a supplied nominal target, .{ ... } now constructs an anonymous record. A structural record annotation provides expected field types. TE161 still rejects an ambiguous or invalid nominal target.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en