Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
5.8 KiB
0115 — same-name consts of different shapes collide across modules (panic / silent clobber)
RESOLVED (2026-06-11). Root cause: the globals registry (
global_names) is last-wins across modules and every read/write/addr/ call site consulted it with no source-awareness;var_declwas not even a selectable raw author. Fix:var_decljoinsRawDeclRef;selectGlobalAuthor(the globals analogue of F2'sselectModuleConst) selects the author own-wins / one-flat-visible / ambiguous-loudly and serves the AUTHOR's per-source global; all bare-identifier global sites (read, addr-of, assignment, fn-ptr call, type inference) route through it.selectModuleConstgained.own_opaqueso an own const author with no materialized value (unsupported shape, e.g. an array::const) blocks borrowing another module's same-named const instead of panicking. The fn-as-VALUE arm admits raw-facts-only authors (an own fn dropped from the global decl list by a flat-merge collision — the 0601testcase). Regression tests: examples/0835, 0836, 0837. The co-blockers also landed: dead-global elimination at emit (unreferenced plain-data globals are not emitted) and 1055/1056 no longer pin global error ordinals — the full std namespace tail is enabled on top.
Symptom. When two modules in one program declare a same-named module
const with DIFFERENT shapes (scalar K : i64 : 4 vs array
K : [4]i64 : .[...]), resolution conflates them instead of selecting
per-author:
- Observed (minimal repro below): compiler PANIC —
unresolved type reached LLVM emission(src/backend/llvm/types.zig:175, the.unresolvedsentinel tripwire). - Observed (full std-tail topology): SILENT WRONG VALUES — a module's
own scalar
Kreads as the other module's array global (prints the array's address or the whole array). Seen corpus-wide whenhash :: #import "modules/std/hash.sx"(hash.sx declares the SHA-256K : [64]i64table) is added to the std.sx namespace tail: examples 0786/0787/0788/0789/0791/0793/0794 (same-name-const family), 0162, 0168 all read hash'sKinstead of their own. - Expected: own-wins / per-author const selection (the documented F2 semantics — readme "Own-wins holds at every one of those sites") applies regardless of the consts' shapes; no cross-shape leakage, no panic.
This blocks the PLAN-STDLIB "full tail" follow-up: fs/process/socket/ json/cli/hash/test cannot join the std.sx namespace tail until same-name consts are robust across every module pulled into every program.
Reproduction (panic variant — minimal, standalone)
// h.sx
K : [4]i64 : .[11, 22, 33, 44];
use_k :: () -> i64 { K[2] }
// main.sx
#import "modules/std.sx";
h :: #import "h.sx";
K : i64 : 4;
main :: () { print("K={} h.use_k={}\n", K, h.use_k()); }
Run main.sx → panic unresolved type reached LLVM emission.
Expected: prints K=4 h.use_k=33.
Reproduction (silent-clobber variant — full topology)
Add the full tail to library/modules/std.sx after the existing
mem/xml/log lines:
fs :: #import "modules/std/fs.sx";
process :: #import "modules/std/process.sx";
socket :: #import "modules/std/socket.sx";
json :: #import "modules/std/json.sx";
cli :: #import "modules/std/cli.sx";
hash :: #import "modules/std/hash.sx";
test :: #import "modules/std/test.sx";
Run bash tests/run_examples.sh → ~50 failures. The const-family
failures (0786 prints a=4318334368 b=4318334368, 0162 prints the whole
64-entry array for K=...) are this bug. (A flat-importing main + a
namespaced array-K module WITHOUT the tail topology resolves correctly —
the silent variant needs the tail's shape, where hash.sx itself
flat-imports std.sx. The panic variant above is the minimal entry point.)
Co-blockers observed in the same experiment (note, possibly separate issues)
- Eager emission bloat: with the tail in place, every program emits
hash's 64-entry
@Ktable plus@OS/@ARCH/@POINTER_SIZEglobals even when unused (visible in every pinned.irsnapshot). Tail modules' globals should emit lazily (only when referenced). - 0601-comptime-meta prints nothing (comptime meta machinery breaks
with the tail in place — root cause unknown, possibly same-name
generic/comptime fn last-wins:
isPlainFreeFnexcludes generic / comptime authors from own-wins rerouting). - 1055/1056 errors-enum-value: user-visible error ints shift when tail modules' error sets join the global error-tag registry (numbering coupling, arguably inherent; snapshot fragility at minimum).
Investigation prompt
Same-name module consts are selected own-wins via selectModuleConst
(F2, src/ir/lower/expr.zig ~1641) over module_const_map — but ARRAY
consts lower as GLOBALS (@K = internal global [4 x i64]), registered in
a different, still last-wins registry (find it: grep the lowering for
where a top-level array const becomes a module global — likely
lowerGlobalDecl / the global-var map in src/ir/lower/decl.zig). The
panic happens because the scalar K's type resolution reads the OTHER
author's array shape (or vice versa) and poisons to .unresolved.
The fix likely needs:
- Source-aware selection for the globals registry, mirroring
selectModuleConst(own-wins, ≥2 flat-visible authors → loud ambiguity) — including the MIXED scalar/array case where the two authors live in different registries today. - The 0786-family examples already pin scalar/scalar own-wins; add a scalar-vs-array pin (the minimal repro above) once fixed.
Verification: run the panic repro (expect K=4 h.use_k=33), then add the
full tail to std.sx and run bash tests/run_examples.sh — the const
family (0786/0787/0788/0789/0791/0793/0794, 0162, 0168) must pass; the
remaining tail failures decompose into co-blockers 1-3 above (file
separately if they persist).