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
Sender.send(Variant(x)) — direct enum-constructor arg lowers as void aggregate → codegen trap (§4.4, §14.14) #671
The #669 fix (storing-method expected-arg types in Sema.method_expected_arg_type) repaired the contextual-variant argument trap for VecSlot.set, VecRange.set, SlotMapSlot.set, HashMapEntry.set, and SlotMap.insert, in both generic and non-generic contexts. The same shape on a channel sender still traps and has a different mechanism.
Also reproduces with a user enum (enum Msg: Ping(i32) …; tx.send(Ping(3))) and with the arg parenthesized. tx.send(3) on chan[i32] works; the typed-intermediate spelling (let v: Option[i32] = Some(3); tx.send(v)) works.
Evidence collected
MIR (--dump-mir): the argument temp is _5: ty14 where ty14 = void — _5 = aggregate(kind=1, tag=0, fields=[const 3ty3]) then call sym9(copy _3, copy _5). The variant aggregate is typed void, so CodegenDispatch.w:3536 finds no destination struct.
MirLower.expr_type honors typed_expr_types for NK_CALL nodes (no void-fallback for calls), so sema's recorded type for the Some(3) node is void or missing.
Sema-side: tx types correctly as Sender[Option[i32]] (probe: unknown-method error text). method_expected_arg_type HAS a Sender.send arg-0 branch (returns the element inst via get_generic_inst_arg), yet under LLDB every method_expected_arg_type return during this file's check is 0 or a small id — the send argument's expected either never reaches check_expr_with_expected or is dropped on a path between the mc arg loop (SemaCheck.w:17874ff) and recording.
Sender.send is NOT in MirLower's intrinsic table (CHAN_SEND classification lives in CodegenDispatch), so the argument lowers through the ordinary sig path (lower_call_arg), which takes sig_param_type — for the generic impl that is not the instantiated element type either. Both layers therefore miss.
analyze cannot produce facts past the codegen failure for this repro.
Workaround
Typed intermediate before the send, as used elsewhere pre-#669.
Suggested next step
Break at Sema.check_expr_with_expected/the 17874 arg loop for the send call under LLDB and observe whether the loop runs, what mc_expected is, and what gets inserted into typed_expr_types for the argument node; then decide whether the fix belongs in the mc loop, the channel method resolution, or MirLower's send arg lowering.
Actual root (deeper and broader than the issue's framing): Sender.send has no sema-recorded signature and no MirLower intrinsic classification, so it lowers through the unresolved-method GENERIC_CALL arm, whose argument lowering never rebinds expected_type. The variant-constructor lowering then did if expected_type != 0: vc_result_ty = expected_type — and in statement position the ambient expectation is void, so the Some(3) aggregate was typed void (dest_sema=14); in a specialized generic body the ambient can be the enclosing fn's return type (the original dest_sema=3). The same unconditional override existed in the bare-ident (None) and shorthand paths. This is the same defect class #634 fixed for comparison operands and #669 masked for eleven storing methods by supplying a correct expected — send was the cell where nothing supplies one and the ambient wins.
Fix: the constructor-call and bare-ident lowerings accept the ambient expected only when sema's strict enum_variant_discriminant_for_type confirms it carries the constructed variant (MirLower's wrapper is unusable as a guard — it falls back to a by-symbol index for any type); the shorthand path stops adopting a void expectation. Legitimate contextual refinement (expected enum instantiation over a generic base) still applies.
Verified matrix:tx.send(Some(3)) round-trips; parenthesized form; user-enum tx.send(Ping(9)); chan[i32] control; the full #669 storing-method matrix and the §14.11 combinator fixtures unchanged-green. Pinned by test/behavior/behav_channel_enum_payload.w.
Split: channel runtime handling of enum payloads is broken independently and pre-existing — a sent None arrives as channel-empty, and matching on a received user enum segfaults (reproduced on the pre-fix installed compiler via typed intermediates) — filed as #672 with the cell matrix.
Note for the record: the earlier LLDB-based claim that method_expected_arg_type returned 0 for the send argument was wrong — name-based breakpoints land post-prologue and the registers were stale; a bounded trace print showed the Sender branch returning the correct element type all along. The check-side typing was never the problem.
Gates on 4664df6: build 0, FIXPOINT, audit:all violations=0, :test all targets ok, test-green/last-green recorded.
Activity
Sema: publish stored-element type for storing-method args (#669)
Docs: record #669 fix and #671 split in handoff
MirLower: ambient expected type must carry the variant it retypes (#671)
ehartford commentedon Jul 16, 2026
Fixed in 4664df6.
Actual root (deeper and broader than the issue's framing):
Sender.sendhas no sema-recorded signature and no MirLower intrinsic classification, so it lowers through the unresolved-method GENERIC_CALL arm, whose argument lowering never rebindsexpected_type. The variant-constructor lowering then didif expected_type != 0: vc_result_ty = expected_type— and in statement position the ambient expectation is void, so theSome(3)aggregate was typed void (dest_sema=14); in a specialized generic body the ambient can be the enclosing fn's return type (the originaldest_sema=3). The same unconditional override existed in the bare-ident (None) and shorthand paths. This is the same defect class #634 fixed for comparison operands and #669 masked for eleven storing methods by supplying a correct expected — send was the cell where nothing supplies one and the ambient wins.Fix: the constructor-call and bare-ident lowerings accept the ambient expected only when sema's strict
enum_variant_discriminant_for_typeconfirms it carries the constructed variant (MirLower's wrapper is unusable as a guard — it falls back to a by-symbol index for any type); the shorthand path stops adopting a void expectation. Legitimate contextual refinement (expected enum instantiation over a generic base) still applies.Verified matrix:
tx.send(Some(3))round-trips; parenthesized form; user-enumtx.send(Ping(9));chan[i32]control; the full #669 storing-method matrix and the §14.11 combinator fixtures unchanged-green. Pinned bytest/behavior/behav_channel_enum_payload.w.Split: channel runtime handling of enum payloads is broken independently and pre-existing — a sent
Nonearrives as channel-empty, and matching on a received user enum segfaults (reproduced on the pre-fix installed compiler via typed intermediates) — filed as #672 with the cell matrix.Note for the record: the earlier LLDB-based claim that
method_expected_arg_typereturned 0 for the send argument was wrong — name-based breakpoints land post-prologue and the registers were stale; a bounded trace print showed the Sender branch returning the correct element type all along. The check-side typing was never the problem.Gates on 4664df6: build 0, FIXPOINT, audit:all violations=0, :test all targets ok, test-green/last-green recorded.
Docs: record #671 fix and #672 split in handoff