✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS the wall of 510_119 one level deeper: a branch constructor nested in
// a flow arm must name the declared payload's fields, not only a declared
// branch. `| then => ok { c: 3, d: 4 }` names a real branch with two fields
// the payload does not declare — the branch-name wall passes it, and the
// field disagreement reached Zig as `no field named 'c'` against
// output_emitted.zig.
import std/io
pub tor pick { x: i64 }
| ok { a: i64, b: i64 }
| bad i64
pick = if(x > 0)
| then => ok { c: 3, d: 4 }
| else => bad 0
pick(x: 1)
| ok o |> std/io:print.ln("{{ o.a:d }}{{ o.b:d }}")
| bad _ |> _
Actual compiler output
error[KORU030]: constructor field 'c' is not a field of branch 'ok' (payload fields: a, b)
--> tests/regression/500_INTEGRATION_TESTING/510_NEGATIVE_TESTS/510_131_nested_record_ctor_names_undeclared_field/input.k:14:1
error[KORU030]: constructor field 'd' is not a field of branch 'ok' (payload fields: a, b)
--> tests/regression/500_INTEGRATION_TESTING/510_NEGATIVE_TESTS/510_131_nested_record_ctor_names_undeclared_field/input.k:14:1
error[KORU030]: branch 'ok' declares payload field 'a' the constructor does not supply — every constructor supplies the field explicitly
--> tests/regression/500_INTEGRATION_TESTING/510_NEGATIVE_TESTS/510_131_nested_record_ctor_names_undeclared_field/input.k:14:1
error[KORU030]: branch 'ok' declares payload field 'b' the constructor does not supply — every constructor supplies the field explicitly
--> tests/regression/500_INTEGRATION_TESTING/510_NEGATIVE_TESTS/510_131_nested_record_ctor_names_undeclared_field/input.k:14:1Must fail at runtime with:
NOT_CONTAINS output_emitted.zig
CONTAINS KORU030
CONTAINS is not a field of branch 'ok'Flows
subflow ~pick click a branch to expand · @labels scroll to their anchor
if (x > 0)
flow ~pick click a branch to expand · @labels scroll to their anchor
pick (x: 1)
Test Configuration
MUST_ERROR