This commit is contained in:
Jakub Doka 2024-11-17 21:25:22 +01:00
parent aa2de502cc
commit bc2dd82eb7
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143

View file

@ -3894,7 +3894,8 @@ impl<'a> Codegen<'a> {
self.ci.ctrl.get() self.ci.ctrl.get()
}; };
self.close_if(lcntrl, rcntrl, then_scope) self.close_if(lcntrl, rcntrl, then_scope)?;
Some(Value::VOID)
} }
Expr::Match { pos, value, branches } => { Expr::Match { pos, value, branches } => {
let value = self.expr(value)?; let value = self.expr(value)?;
@ -3983,9 +3984,9 @@ impl<'a> Codegen<'a> {
for (lcntrl, then_scope) in scopes.into_iter().rev() { for (lcntrl, then_scope) in scopes.into_iter().rev() {
if let Some(v) = self.close_if(lcntrl, rcntrl, then_scope) if let Some(v) = self.close_if(lcntrl, rcntrl, then_scope)
&& v.id != VOID && v != VOID
{ {
rcntrl = v.id; rcntrl = v;
} }
} }
@ -4002,18 +4003,18 @@ impl<'a> Codegen<'a> {
} }
} }
fn close_if(&mut self, lcntrl: Nid, rcntrl: Nid, mut then_scope: Scope) -> Option<Value> { fn close_if(&mut self, lcntrl: Nid, rcntrl: Nid, mut then_scope: Scope) -> Option<Nid> {
if lcntrl == Nid::MAX && rcntrl == Nid::MAX { if lcntrl == Nid::MAX && rcntrl == Nid::MAX {
then_scope.clear(&mut self.ci.nodes); then_scope.clear(&mut self.ci.nodes);
return None; return None;
} else if lcntrl == Nid::MAX { } else if lcntrl == Nid::MAX {
then_scope.clear(&mut self.ci.nodes); then_scope.clear(&mut self.ci.nodes);
return Some(Value::VOID); return Some(VOID);
} else if rcntrl == Nid::MAX { } else if rcntrl == Nid::MAX {
self.ci.scope.clear(&mut self.ci.nodes); self.ci.scope.clear(&mut self.ci.nodes);
self.ci.scope = then_scope; self.ci.scope = then_scope;
self.ci.ctrl.set(lcntrl, &mut self.ci.nodes); self.ci.ctrl.set(lcntrl, &mut self.ci.nodes);
return Some(Value::VOID); return Some(VOID);
} }
self.ci.ctrl.set( self.ci.ctrl.set(
@ -4029,7 +4030,7 @@ impl<'a> Codegen<'a> {
self.tys, self.tys,
); );
then_scope.clear(&mut self.ci.nodes); then_scope.clear(&mut self.ci.nodes);
Some(Value::new(self.ci.ctrl.get()).ty(ty::Id::VOID)) Some(self.ci.ctrl.get())
} }
fn gen_enum_variant(&mut self, pos: Pos, e: ty::Enum, intrnd: Option<Ident>) -> Option<Value> { fn gen_enum_variant(&mut self, pos: Pos, e: ty::Enum, intrnd: Option<Ident>) -> Option<Value> {