diff --git a/lang/src/son.rs b/lang/src/son.rs index 1e4be551..1a85bc28 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -2628,6 +2628,15 @@ impl Pool { fn restore_ci(&mut self, dst: &mut ItemCtx) { self.used_cis -= 1; dst.scope.clear(&mut dst.nodes); + dst.loops.drain(..).for_each(|mut l| { + l.ctrl.map(|c| { + if c.is_live() { + c.remove(&mut dst.nodes); + } + }); + l.scope.clear(&mut dst.nodes); + l.ctrl_scope.map(|mut s| s.clear(&mut dst.nodes)); + }); mem::take(&mut dst.ctrl).remove(&mut dst.nodes); *dst = mem::take(&mut self.cis[self.used_cis]); } @@ -5518,7 +5527,6 @@ impl<'a> Codegen<'a> { fn infer_type(&mut self, expr: &Expr) -> ty::Id { self.pool.save_ci(&self.ci); let ty = self.expr(expr).map_or(ty::Id::NEVER, |v| v.ty); - self.pool.restore_ci(&mut self.ci); ty }