fix(diagnostics): reject reserved type-name bindings in every module (issue 0077)
The issue-0076 reserved-type-name binding diagnostic only ran over main-file decls, so an imported module (or the stdlib) could still declare `s2 := ...` and reach lowering, where the address-of family loads the whole aggregate and passes it by value to a `ptr` param — LLVM verifier abort. Extend coverage to every compiled module: a dedicated `checkBindingNames` walk (in semantic_diagnostics.zig) visits every var/`:=`/typed-local binding name and function/lambda/struct-method parameter at any depth, with NO main-file filter, descending the `namespace_decl` that a `mod :: #import` wraps so imported-module decls are reached. It tracks each module's source_file (save/restore per node) so the diagnostic renders against the imported module's text. Rejection still defers to the parser's `Type.fromName` classifier; the unknown-type check (0064) stays main-file-only. No lowering special-case; `.identifier`-only address-of paths are unchanged. Stdlib audit: the only reserved-name bindings under library/ were two `u1` locals in ui/renderer.sx (UV coords) — renamed to u_min/u_max/v_min/v_max. Regression test: examples/1120-diagnostics-imported-reserved-type-name.sx (+ companion mod.sx) — an imported `s2 := ...` now emits the clean diagnostic at the import's declaration site (exit 1), not an LLVM abort. Resolves issues 0076 (coverage extension) and 0077.
This commit is contained in:
@@ -31,8 +31,18 @@
|
||||
> both `update(@h, …)` and `h.update(…)`.
|
||||
>
|
||||
> Pre-existing example `examples/0904-...` declared locals `s1`/`s2` (incidental
|
||||
> names); renamed to `filled`/`empty`. Scope: main-file decls only, matching the
|
||||
> pass's existing trusted-imports convention.
|
||||
> names); renamed to `filled`/`empty`.
|
||||
>
|
||||
> **Coverage extension (issue 0077).** The first landing scoped the binding
|
||||
> check to main-file decls (matching the unknown-type check's trusted-imports
|
||||
> convention); an imported module could still declare `s2 := …` and hit the
|
||||
> original LLVM verifier abort. The reserved-name binding diagnostic now runs
|
||||
> over EVERY compiled module — imported user modules (descending the
|
||||
> `namespace_decl` an `mod :: #import` wraps) AND the stdlib `library/` — and
|
||||
> the two `u1` locals in `library/modules/ui/renderer.sx` were renamed
|
||||
> accordingly. The unknown-type check (issue 0064) stays main-file-only. See
|
||||
> issue 0077 for the imported-module facet and its pinned regression test
|
||||
> `examples/1120-diagnostics-imported-reserved-type-name.sx`.
|
||||
|
||||
## Symptom (how it first surfaced)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user