fix: comptime reg->value bridge for array-in-aggregate + clean abort on comptime-init failure (issue 0167)
(C) regToValue (comptime_vm.zig) gained no array arm, so a #run returning an aggregate containing an array bailed 'reg->value: aggregate shape not bridged yet'. Add an .array arm: read N elements at stride typeSizeBytes(elem) from the array address, bridge each recursively via regToValue -> an .aggregate Value (serializeAggregateValue already emits arrays). Composes with struct fields, nested arrays, array-of-structs, and the ?Arr optional payload; unbridgeable elements bail loudly. (E) A global failing #run proceeded into LLVM emission and panicked 'unresolved type reached LLVM emission' when the unresolved const was used. Add 'if (self.comptime_failed) return;' in emit() after Pass 0 so it aborts cleanly (exit 1, the comptime diagnostic) across run/ir/build. Regression: examples/comptime/0644-comptime-run-array-aggregate.sx. Verified by 3 adversarial reviews, suite 793/0. Filed separate bugs found during review: 0181 (optional-chain ?. to array field + index panics), 0182 (body-local #run unbridged silently miscompiles).
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
# 0167 — comptime `#run` returning an aggregate that contains an array fails the reg→value bridge (+ unclean recovery)
|
||||
|
||||
> **RESOLVED.** (C) Added an `.array` arm to `regToValue` in
|
||||
> `src/ir/comptime_vm.zig`: reads N elements at stride `typeSizeBytes(elem)` from
|
||||
> the array's address and recursively bridges each via `regToValue(elem_ty)` →
|
||||
> an `.aggregate` Value (`serializeAggregateValue` already handles arrays).
|
||||
> Composes with struct-field walks, nested arrays, array-of-structs, and the
|
||||
> `?Arr` optional payload; unbridgeable element types bail loudly. (E) Added
|
||||
> `if (self.comptime_failed) return;` in `emit()` (`src/ir/emit_llvm.zig`) after
|
||||
> Pass 0, so a GLOBAL failing `#run` aborts cleanly (exit 1, the `comptime init
|
||||
> of 'X' failed: …` diagnostic) instead of panicking `unresolved type reached
|
||||
> LLVM emission` — verified across `sx run`/`ir`/`build`. Regression:
|
||||
> `examples/comptime/0644-comptime-run-array-aggregate.sx`. Verified by 3
|
||||
> adversarial reviews; suite 793/0. The issue's (E) repro `A?.xs[0]` now routes
|
||||
> to two SEPARATE pre-existing bugs filed during review: **0181** (optional-chain
|
||||
> `?.` to an array field then `[idx]` → unresolved panic, pure-runtime) and
|
||||
> **0182** (body-local `#run` of an unbridged shape silently miscompiles —
|
||||
> `lowerInlineComptime` doesn't set `comptime_failed`). Both are out of 0167's
|
||||
> reg→value-bridge scope.
|
||||
## Symptom
|
||||
|
||||
Two related defects:
|
||||
|
||||
Reference in New Issue
Block a user