✓
Passing This code compiles and runs correctly.
Code
// TEST: A stray ']' before any '[' in a struct payload must be rejected
// LOUDLY as an unbalanced bracket — not silently mis-split.
//
// MUST_FAIL: unbalanced ']'
//
// `splitFieldsRespectingBrackets` walks the payload content tracking
// `bracket_depth`. A closing ']' with no matching '[' drives the depth
// negative, so the `bracket_depth == 0` gate stops recognizing the top-level
// comma as a field separator. The two fields collapse into one, and
// `parseShape` then fires a WRONG diagnostic ("single field in braces").
//
// The honest behavior: detect the negative depth and report the real cause —
// an unbalanced closing bracket — at the earliest layer (maximalist parser).
~import std/io
~pub event probe {}
| got { a: i32], b: u8 }
~std/io:print.ln("hi")
Must fail at frontend compile:
Parsing or type-checking must reject the program.
Expected compiler error
error[PARSE004]: unbalanced ']' in payload shape — closing bracket has no matching '['
--> tests/regression/100_PARSER/100_081_unbalanced_bracket_in_payload/input.kz:18:1
|
18 | | got { a: i32], b: u8 }
| ^
Error Verification
Actual Compiler Output
error[PARSE004]: unbalanced ']' in payload shape — closing bracket has no matching '['
--> tests/regression/100_PARSER/100_081_unbalanced_bracket_in_payload/input.kz:18:1
|
18 | | got { a: i32], b: u8 }
| ^Test Configuration
MUST_FAIL