✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS: the each-name-once law holds across nesting levels — every leaf
// of a destructure emits one `const <name>`, so `{ user: { x }, x }`
// binds `x` twice and refuses PARSE010 at the arm line. The nested-only
// sibling `{ user: { y }, x }` binds distinct leaves and stays legal.
~import std/io
const std = @import("std");
const Point = struct { x: i64, y: i64 };
~tor fetch { id: i64 }
| found { user: Point, x: i64 }
| missing
~proc fetch|zig {
if (id == 1) return .{ .found = .{ .user = .{ .x = 1, .y = 2 }, .x = 9 } };
return .{ .missing = .{} };
}
~fetch(id: 1)
| found { user: { x }, x } |> std/io:print.ln("x = {{ x:d }}")
| missing |> std/io:print.ln("nope")
Actual compiler output
error[PARSE010]: field 'x' is bound twice in the destructure — a field list takes each name once
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_273_destructure_dup_across_nesting_refused/input.kz:19:0
|
19 | | found { user: { x }, x } |> std/io:print.ln("x = {{ x:d }}")
| ^
hint: drop one, or rename it — the list cannot carry two 'x'Frontend must reject with:
CONTAINS error[PARSE010]
CONTAINS 'x'
CONTAINS bound twice
ERROR_AT 19
NOT_CONTAINS output_emitted.zigFlows
flow ~fetch click a branch to expand · @labels scroll to their anchor
fetch (id: 1)
Test Configuration
MUST_ERROR