✓
Passing This code compiles and runs correctly.
Code
// Test 210_021: Struct Field Punning Shorthand
// When field value is an expression like `p.x`, infer field name from last segment
//
// Syntax: { p.x, p.y } should expand to { x: p.x, y: p.y }
~import std/io
pub const Point = struct { x: i32, y: i32 };
~tor make-point { x: i32, y: i32 } -> Point
~proc make-point|zig {
return Point{ .x = x, .y = y };
}
~tor use-point { p: Point } -> { x: i32, y: i32 }
// Shorthand: { p.x, p.y } should become { x: p.x, y: p.y }
~use-point -> { p.x, p.y }
// Test it
~make-point(x: 10, y: 20): pt |> use-point(p: pt): r |> std/io:print.ln("punning works: x={{ r.x:d }}, y={{ r.y:d }}")
Actual
punning works: x=10, y=20
Expected output
punning works: x=10, y=20
Flows
flow ~make-point click a branch to expand · @labels scroll to their anchor
make-point (x: 10, y: 20)
Test Configuration
MUST_RUN