fix: comptime VM reg→value bridge for optional results (issue 0162)
Add an .optional arm to regToValue in comptime_vm.zig: read the
has_value flag at offset sizeof(child), bridge the payload recursively
into a { payload, i1=true } aggregate when set, yield .null_val (zero
{T,i1}) when clear or the bare null sentinel. Matching serialize arm in
serializeAggregateValue (emit_llvm.zig). Pointer/?Closure/?Protocol-child
optionals and array-payload aggregates bail loudly, not silently.
Regression: examples/comptime/0643-comptime-run-optional-aggregate.sx
(present ?T, present ?i64, null ?i64). Verified by 3 adversarial reviews.
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
# 0162 — `#run` returning an optional aggregate fails the comptime VM reg→value bridge
|
||||
|
||||
> **RESOLVED.** Root cause: the comptime VM's `regToValue` bridge
|
||||
> (`src/ir/comptime_vm.zig`) had no `.optional` arm, so any OPTIONAL-typed
|
||||
> `#run` result hit the `"aggregate shape not bridged yet"` bail. Fix: added an
|
||||
> `.optional` arm that reads the has_value flag (at offset `sizeof(child)`),
|
||||
> bridges the payload recursively into a `{ payload, i1=true }` aggregate when
|
||||
> set, and yields `.null_val` (→ zero `{T, i1}`) when clear or the bare null
|
||||
> sentinel; plus a matching serialize arm in `serializeAggregateValue`
|
||||
> (`src/ir/emit_llvm.zig`). Pointer/`?Closure`/`?Protocol`-child optionals and
|
||||
> array-payload aggregates bail loudly (out of scope, not silent). Regression
|
||||
> test: `examples/comptime/0643-comptime-run-optional-aggregate.sx` (present
|
||||
> `?T`, present `?i64`, null `?i64`). Verified by 3 adversarial reviews.
|
||||
|
||||
## Symptom
|
||||
|
||||
A `#run` (or comptime const init) whose function returns an OPTIONAL value
|
||||
|
||||
Reference in New Issue
Block a user