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 referenced with call parens (Color.Red()) passes with check but fails codegen #566
Found while investigating #563 (test/lexer, test/parser wiring). The old paren-call style for plain enum variants is accepted by sema but dies in codegen.
Repro
// enum_variant_parens.w
enum Color: i32:
Red = 1
Blue = 2
fn main:
assert(Color.Red() == Color.Red)
print("ok")
$ with check enum_variant_parens.w
ok
$ with build enum_variant_parens.w
error: aggregate rvalue missing destination struct type fn=main count=0 dest_sema=84 current_ret=void
error: code generation failed
Expected vs actual
Expected: either the paren form lowers identically to Color.Red (it's a unit variant of an i32-repr enum), or sema rejects it with a real diagnostic.
Actual: with check accepts it, codegen fails with an internal aggregate rvalue missing destination struct type error. Sema and codegen disagree about what the expression is.
Same failure with cross-module pub enums, in comparisons (x == Color.Red()), and in argument position. Color.Red (no parens) works everywhere.
Context / workaround
test/lexer/*.w and test/parser/parser_unit_test.w use this paren style pervasively (TokenKind.TK_EOF(), NodeKind.NK_INT_LIT()); the #563 fix will drop the parens in those tests as API drift, so this issue is only about the sema/codegen mismatch itself.
Fixed by the commit above: Color.Red() (payloadless disc-enum variant in CALL form) now lowers to its repr-backed int constant in MirLower.lower_static_enum_variant_call — the RK_AGGREGATE path was only ever valid for payload-bearing (struct-repr) enums. Pinned by behav_enum_variant_paren_call. §4.4; full gates green.
Activity
Wire test/lexer and test/parser into the build test group
ehartford commentedon Jul 2, 2026
Fixed by the commit above: Color.Red() (payloadless disc-enum variant in CALL form) now lowers to its repr-backed int constant in MirLower.lower_static_enum_variant_call — the RK_AGGREGATE path was only ever valid for payload-bearing (struct-repr) enums. Pinned by behav_enum_variant_paren_call. §4.4; full gates green.
Fix enum-variant construction typing in MIR lowering (#566, #586)
test: coverage-sweep batch 2 (#483 #484 #522 #493 #494 #514 #515 #532)