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
var best = None passes check, then codegen fails: aggregate enum payload missing destination payload type #2103
type Pick { score: i32 = 0 }
fn best_of(xs: &Vec[i32]) -> Option[Pick]:
var best = None
for x in xs:
if x > 2: best = Some(Pick { score: x })
best
fn main:
var xs = Vec.new()
xs.push(1)
xs.push(5)
match best_of(&xs):
Some(p) => print(f"{p.score}")
None => print("none")
$ with check optnone.w
ok
$ with run optnone.w
error: aggregate enum payload missing destination payload type fn=best_of variant=0
error: code generation failed
Expected
It prints 5. Sema infers best: Option[Pick] from the later Some(Pick {...}) assignment and the return type, which is why with check is clean, but code generation never receives the payload type for the None initializer. One stage accepts what the next can't lower (D65: one authoritative producer per semantic fact).
Writing var best: Option[Pick] = None works around it. WIPE keeps three such annotations (src/account.w, next_unlock and next_rank) until this is fixed. Found while removing redundant annotations from withlang-dev/wipe.
Activity
sema: a bare variant of a generic enum is a pending generic binding (#…
mir: the typed validator rejects a local whose type is a generic decl…