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
Enum-variant construction (Some(x)) as an operator operand has no codegen destination type #634
Constructing an enum variant inline as an operand of a binary/default operator — opt == Some(2), Some(5) ?? rhs — fails codegen: 'aggregate rvalue missing destination struct type fn=main count=1'. Binding it first with an annotation works: let s: Option[i32] = Some(2) then compare/use.
Repro
fn main:
let r: Option[i32] = Some(2)
if r == Some(2): // error: aggregate rvalue missing destination struct type
print("eq")
Also (Some(5) ?? boom()).
Spec §4.4 / §4.3c
Expected-type-driven enum-variant construction. Sibling of #566/#586 (both fixed via MirLower expected_type threading, commit e9956f2) but in a different context: the comparison/default-operator operand position doesn't thread the expected type into the Some(...) aggregate. Candidate: check_binary/check_default_op operand expected-type propagation → MirLower aggregate dest.
Found
Coverage sweep #515/#493, 2026-07-03. Worked around in those fixtures via match/bound-locals.
Fixed in 058f38c. lower_bin_op lowered a comparison's operand with the ambient expected type (bool for if a == b:), so an enum-variant-constructor operand like Some(2) in r == Some(2) built its aggregate with the comparison's type — 'aggregate rvalue missing destination struct type'. Fix: for EQ/NEQ/LT/GT/LTE/GTE, lower each operand with the OTHER operand's type as expected (generalizing the #586 bare-None rebind). Verified across Option/Result and both operand orders; plain scalar comparisons unaffected. Full gate green.
Activity
test: coverage-sweep batch 2 (#483 #484 #522 #493 #494 #514 #515 #532)
ehartford commentedon Jul 14, 2026
Fixed in 058f38c. lower_bin_op lowered a comparison's operand with the ambient expected type (bool for
if a == b:), so an enum-variant-constructor operand likeSome(2)inr == Some(2)built its aggregate with the comparison's type — 'aggregate rvalue missing destination struct type'. Fix: for EQ/NEQ/LT/GT/LTE/GTE, lower each operand with the OTHER operand's type as expected (generalizing the #586 bare-None rebind). Verified across Option/Result and both operand orders; plain scalar comparisons unaffected. Full gate green.MIR: lower comparison operands with the other operand's expected type (…