A function cannot return an open record while hiding its extra fields
Gap
fun make() -> { x: i64, .. } is rejected with T0032. Such a return type would be an
existential: the callee picks the row and the caller sees x plus an extra row it cannot name.
The language has no form for it.
The cases that motivate it are covered by other forms:
- a private function omits its return type and the exact record is inferred, so the caller reads every field;
- a
publicfunction must write a return type (T0010) and writes the record in full,-> { x: i64, y: i64 }; - a function whose row comes from an argument names it,
-> { x: i64, ..R }.
Impact
An API cannot return a record and promise only some of its fields. A public function that returns a record exposes its exact field set, so adding a field to it changes its type.
Affects
Resolution
Accepted by RFC-0181, which records the decision and what an existential return would cost: an opaque, rigid remainder carried through the caller's inference, a distinct type per call site, and a rule for storing such a value. RFC-0179 gives the caller the whole record, so soundness is not the obstacle. Reopen when a real API needs to hide fields.