Fix match codegen

This commit is contained in:
Shunsuke Shibayama 2022-11-16 18:59:38 +09:00
parent d63b018371
commit 771be313a9
7 changed files with 173 additions and 80 deletions

View file

@ -2241,6 +2241,8 @@ impl From<&Identifier> for Field {
}
impl Identifier {
pub const UBAR: &Self = &Self::new(None, VarName::from_static("_"));
pub const fn new(dot: Option<Token>, name: VarName) -> Self {
Self { dot, name }
}

View file

@ -466,7 +466,7 @@ impl Desugarer {
);
}
}
VarPattern::Ident(_i) => {
VarPattern::Ident(_) | VarPattern::Discard(_) => {
let block = body
.block
.into_iter()
@ -476,7 +476,6 @@ impl Desugarer {
let def = Def::new(Signature::Var(v), body);
new.push(Expr::Def(def));
}
_ => {}
},
Expr::Def(Def {
sig: Signature::Subr(mut subr),
@ -582,11 +581,10 @@ impl Desugarer {
);
}
}
VarPattern::Ident(_ident) => {
VarPattern::Ident(_) | VarPattern::Discard(_) => {
let def = Def::new(Signature::Var(sig.clone()), body);
new_module.push(Expr::Def(def));
}
_ => {}
}
}