diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index 0af371278..6246dc217 100644 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -427,6 +427,7 @@ impl Unifier { let mut all_names: Vec<_> = signature.args.iter().map(|v| (v.name, v.ty)).rev().collect(); for (i, t) in posargs.iter().enumerate() { if signature.args.len() <= i { + self.restore_snapshot(); return Err(TypeError::new( TypeErrorKind::TooManyArguments { expected: signature.args.len(), got: i }, *loc, @@ -483,6 +484,7 @@ impl Unifier { } self.unify_cache.clear(); if self.unification_table.unioned(a, b) { + self.discard_snapshot(snapshot); Ok(()) } else { let result = self.unify_impl(a, b, false); diff --git a/nac3core/src/typecheck/unification_table.rs b/nac3core/src/typecheck/unification_table.rs index 708641546..43ef06375 100644 --- a/nac3core/src/typecheck/unification_table.rs +++ b/nac3core/src/typecheck/unification_table.rs @@ -61,6 +61,7 @@ impl UnificationTable { if self.ranks[a] < self.ranks[b] { std::mem::swap(&mut a, &mut b); } + self.log.push(Action::Parent { key: b, original_parent: a }); self.parents[b] = a; if self.ranks[a] == self.ranks[b] { self.log.push(Action::Rank { key: a, original_rank: self.ranks[a] });