020 field punning

✓ Passing This code compiles and runs correctly.

Code

// Test 210_020: Struct Field Punning
// When field value matches field name, allow shorthand: { x, y } instead of { x: x, y: y }
//
// This is the "punning" pattern common in many languages.
// The emitter should expand { c.ast, c.code } to { ast: c.ast, code: c.code }

~import "$std/io"

~event data { x: i32, y: i32 }
| result { x: i32, y: i32 }

// Explicit field names (always works)
~data = result { x: x, y: y }

// Test it
~data(x: 10, y: 20)
| result _ |> std.io:print.ln("explicit works")
input.kz

Expected Output

explicit works

Test Configuration

MUST_RUN