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.5 KiB
0094 — assigning to a missing struct field panics with "unresolved type reached LLVM emission"
RESOLVED (F0.10). Root cause: the lvalue field lookup never diagnosed a missing field. In
Lowering.lowerAssignment's.field_accesstarget path (src/ir/lower.zig),field_tystarted as.unresolved; when no struct field matched, the code still builtptrTo(field_ty)/structGepTypedand stored — so a pointer-to-.unresolvedreached LLVM emission and tripped thesrc/backend/llvm/types.zigtripwire. The nested lvalue-pointer path (Lowering.lowerExprAsPtr's.field_accessfallback) had the sibling defect: on a miss it returnedstructGepTyped(obj_ptr, 0, .i64, obj_ty)— a silent field-0/.i64default.Fix (
src/ir/lower.zig): all three lvalue field-store sites — single assignment, address-of, and multi-target assignment — route field resolution through one shared helper,fieldLvaluePtr(obj_ptr, obj_ty, field), which resolves struct fields, union/tagged-union direct fields, promoted anonymous-struct union members, tuple elements, and vector lanes (reusingvectorLaneIndex), and returnsnull(no field 0 /.unresolved/.i64default) when nothing matches. Each caller emits the read path's field-not-found diagnostic (emitFieldError) on anullresult:
lowerAssignment.field_accesstarget — delegates tofieldLvaluePtr; its own duplicated union / promoted / tuple / vector / struct walk is deleted (issue-0083 two-resolver divergence removed).lowerExprAsPtr.field_access— delegates tofieldLvaluePtr, so the address-of path resolves promoted union members (@v.x) — not only direct union fields — and a genuine miss errors. The.i64sentinel is gone.lowerMultiAssign.field_accesstarget — replaced its struct-only loop (which defaultedfield_idx 0/field_ty .unresolvedon a miss, silently storing into field 0 —p.q, y = 2, 3printedx=2 y=3) with the sharedfieldLvaluePtr; a missing field now errors, and a valid promoted-union / tuple member at a non-zero offset stores into its own slot, not field 0.
fieldLvaluePtrtypes every GEP*field_ty(a pointer to the field), the convention the single-assign path always used:emitStorereads the store-target pointer's IR type and unwraps exactly one.pointerlevel to find the stored value's type. The earlierlowerExprAsPtr/lowerMultiAssignwalks typed the GEP with the bare field value type, so a field whose own type is a pointer-to-aggregate (*Pair, a two-pointer struct) madeemitStoreunwrap to the aggregate andcoerceArg's closure auto-promotion store a 16-byte{ptr,null}struct over the 8-byte slot — clobbering the neighbouring field. Consolidating all three sites onto the one*field_tyresolver preserves single-assign and fixes that pre-existing multi-assign / address-of clobber.All sites reuse
emitFieldError(the exact facility the read pathlowerFieldAccessOnTypeuses), so the read and write paths reject identically. Thesrc/backend/llvm/types.zigtripwire is untouched — the fix is to never produce.unresolvedfor a missing-field store.Regression tests:
examples/1145-diagnostics-missing-struct-field-assign.sx(negative — single-assign, address-of, AND multi-assign missing-field all error, exit 1),examples/0165-types-nested-struct-field-assign.sx(positive — nested struct field write + address-of a matched field),examples/0166-types-union-promoted-member-lvalue.sx(positive — promoted union member written and address-of'd, including a non-zero offset member),examples/0167-types-ptr-to-aggregate-field-store.sx(positive — a*Pairfield stored via all three lvalue sites leaves the neighbour intact), and three lowering unit tests insrc/ir/lower.test.zig(single- and multi-assign missing-field field-not-found, plus the*field_tyGEP convention).
Symptom
Assigning to a nonexistent struct field (p.q = ...) panics during LLVM emission instead of reporting a source diagnostic.
Observed: the compiler reaches the .unresolved LLVM tripwire in src/backend/llvm/types.zig:175 via emitStore.
Expected: a normal compile error like field 'q' not found on type 'Point', matching the read-field diagnostic path.
Reproduction
Point :: struct { x: i64; }
main :: () {
p := Point.{ x = 1 };
p.q = 2;
}
Running ./zig-out/bin/sx run repro.sx currently panics with:
panic: unresolved type reached LLVM emission — a type resolution failure was not diagnosed/aborted
Investigation prompt
Fix issue 0094 in the sx compiler: assigning to a missing struct field (p.q = 2) panics with .unresolved reaching LLVM emission instead of emitting a field-not-found diagnostic.
Suspected area: src/ir/lower.zig, especially Lowering.lowerAssignment's .field_access target path around the struct-field lookup (field_ty starts as .unresolved, no matched field diagnoses, then ptrTo(field_ty) is stored) and the related Lowering.lowerExprAsPtr field-access fallback that returns structGepTyped(obj_ptr, 0, .i64, obj_ty) on lookup failure. The fix should make failed lvalue field lookup loud, reusing emitFieldError(obj_ty, field, span) or equivalent, and should not use .i64, .void, or any real type as a sentinel.
Verification: run the repro and expect exit 1 with a source diagnostic field 'q' not found on type 'Point'; no LLVM panic. Then run zig build, zig build test, and bash tests/run_examples.sh.