You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sema: contextual generic enum arg (slot.set(Some(x))) typed as payload T, not Option[T] → codegen trap (§4.4) #669
§4.4 enum variant shorthand / contextual enum construction: a variant expression in a context whose expected type is a known enum must type as the enum. This holds for the typed-binding spelling but not for the direct generic method-argument spelling.
Minimal repro (self-contained, checked)
fn run[T](x: T) -> T:
let values: Vec[Option[T]] = Vec.new()
let empty: Option[T] = None
values.push(empty)
with values.slot(0) as mut slot:
slot.set(Some(x))
values.get(0).unwrap()
fn main:
assert(run(5) == 5)
print("ok")
Expected vs actual
Expected: prints ok (as the typed-intermediate spelling does).
Actual (committed v0.15.1-era compiler and current main):
Contrast the typed-binding None in the same body: _5: ty232 (Option[i32]) — correct.
So Sema's contextual variant typing for a generic method-call argument records the payload type T instead of Option[T]; MirLower gives the aggregate temp that sema type; codegen resolves no struct type and traps with no source location.
Root cause (one level deeper than the original report): the trap was not generic-body-specific. Storing builtins (VecSlot.set, VecRange.set, SlotMapSlot.set, HashMapEntry.set, SlotMap.insert) published no expected argument type from Sema.method_expected_arg_type, so a contextual variant-constructor argument never learned its enum — in any context. The non-generic spelling slot.set(Some(5)) trapped identically (dest_sema=14 = void). The generic-body report was just the first place it was noticed.
Fix:method_expected_arg_type now returns the stored element type for the storing-method family, mirroring the case list method_arg_stores_value already enumerates. This feeds both check-time contextual typing (check_expr_with_expected in the method-arg loop) and MirLower's intrinsic argument lowering, so the variant aggregate gets its real enum destination.
Verified matrix (all ok post-fix; each trapped or was unexercised pre-fix): generic + non-generic VecSlot.set, VecRange.set value arg, SlotMapSlot.set, HashMapEntry.set, SlotMap.insert, plus the already-working controls (Vec.push, HashMap/HashSet.insert, or_insert, replace, plain generic fn args). Pinned by test/behavior/behav_contextual_enum_storing_args.w.
The typed-intermediate workarounds in lib/std/task.w are removed; the #489 combinator fixtures and the drop-bearing-payload allocator differential are unchanged-green with the direct spelling.
Split:Sender.send(Some(x)) shows the same symptom but a different mechanism (send is not a MirLower intrinsic; its argument lowers through the sig path, and the check-time expected observably never lands) — moved to #671 with the LLDB/MIR evidence.
Activity
std.task: #489 collection-await correctness; E0921 evidence at call s…
Sema: publish stored-element type for storing-method args (#669)
ehartford commentedon Jul 15, 2026
Fixed in 6518916.
Root cause (one level deeper than the original report): the trap was not generic-body-specific. Storing builtins (VecSlot.set, VecRange.set, SlotMapSlot.set, HashMapEntry.set, SlotMap.insert) published no expected argument type from
Sema.method_expected_arg_type, so a contextual variant-constructor argument never learned its enum — in any context. The non-generic spellingslot.set(Some(5))trapped identically (dest_sema=14= void). The generic-body report was just the first place it was noticed.Fix:
method_expected_arg_typenow returns the stored element type for the storing-method family, mirroring the case listmethod_arg_stores_valuealready enumerates. This feeds both check-time contextual typing (check_expr_with_expectedin the method-arg loop) and MirLower's intrinsic argument lowering, so the variant aggregate gets its real enum destination.Verified matrix (all
okpost-fix; each trapped or was unexercised pre-fix): generic + non-generic VecSlot.set, VecRange.set value arg, SlotMapSlot.set, HashMapEntry.set, SlotMap.insert, plus the already-working controls (Vec.push, HashMap/HashSet.insert, or_insert, replace, plain generic fn args). Pinned bytest/behavior/behav_contextual_enum_storing_args.w.The typed-intermediate workarounds in lib/std/task.w are removed; the #489 combinator fixtures and the drop-bearing-payload allocator differential are unchanged-green with the direct spelling.
Split:
Sender.send(Some(x))shows the same symptom but a different mechanism (send is not a MirLower intrinsic; its argument lowers through the sig path, and the check-time expected observably never lands) — moved to #671 with the LLDB/MIR evidence.Gates on 6518916: build 0, FIXPOINT, audit:all violations=0, :test GATES EXIT 0, test-green/last-green recorded.
Docs: record #669 fix and #671 split in handoff