The reserved/builtin-type-name binding diagnostic was a hand-walked subset
of binding-bearing AST nodes with a silent `else => {}`, so each review
found another syntactic binding form that bypassed it and hit the original
LLVM verifier abort: destructure names (`s2, x := …`), `impl` method
params/locals, and `if` / `while` / `for` / match-arm / `catch` / `onfail`
captures.
Rewrite `checkBindingNames` (src/ir/semantic_diagnostics.zig) as an
EXHAUSTIVE `switch` over every `Node.Data` tag with NO `else` arm — a future
binding-bearing node type now fails to compile until it is handled here, so
coverage is enforced by the compiler instead of a hand-maintained list. The
check stays in the pre-lowering semantic pass rather than moving to the
`Scope.put` scope-registration choke point: lowering is lazy, so an
uncalled function's bindings never reach `Scope.put`, yet they must still be
rejected at their declaration (e.g. the never-called `takes_u8` in 1119).
No lowering special-case; `lower.zig` unchanged.
Regression tests (fail-before: LLVM abort or silent accept → pass-after:
clean diagnostic, exit 1):
- 1121 control-flow: destructure, if/while bindings, for capture+index,
match-arm capture
- 1122 impl-block method: reserved param AND reserved local
- 1123 catch + onfail tag bindings
- 1124 destructure name reserved in an imported module
Existing 0125 / 1119 / 0135 / 1120 tests kept; full suite 368 passed.
31 lines
1.3 KiB
Plaintext
31 lines
1.3 KiB
Plaintext
// Reserved/builtin type names are rejected as binding NAMES across every
|
|
// control-flow and destructuring form, not just plain `var`/param decls: a
|
|
// destructure name (`s2`), an `if`/`while` optional binding (`u8`/`s16`), a
|
|
// `for` capture and index name (`bool`/`s32`), and a match-arm capture
|
|
// (`string`). Each spelling parses as a `.type_expr`, so the address-of family
|
|
// in lowering mis-lowers it (a loaded aggregate passed by value to a `ptr`
|
|
// param → LLVM verifier abort). The declaration-site diagnostic comes from one
|
|
// EXHAUSTIVE binding-name walk, so no syntactic binding form can slip through.
|
|
//
|
|
// Regression (issue 0076, attempt-4 coverage). Expected: one error per
|
|
// offending name; exit 1 — NOT an LLVM verifier abort.
|
|
#import "modules/std.sx";
|
|
|
|
pair :: () -> (s64, s64) { (1, 2) }
|
|
maybe :: () -> ?s64 { return null; }
|
|
|
|
main :: () -> s32 {
|
|
s2, rest := pair(); // destructure name
|
|
if u8 := maybe() { } // if optional binding
|
|
while s16 := maybe() { break; } // while optional binding
|
|
xs := [3]s64.{ 10, 20, 30 };
|
|
for xs: (bool) { } // for capture name
|
|
for xs: (v, s32) { } // for index name
|
|
opt: ?s64 = 5;
|
|
r := if opt == { // match-arm capture
|
|
case .some: (string) { 0 }
|
|
case .none: { 0 }
|
|
};
|
|
return 0;
|
|
}
|