nac3core/typecheck: fixed incorrect rollback
This commit is contained in:
parent
e710b6c320
commit
0686e83f4c
@ -427,6 +427,7 @@ impl Unifier {
|
|||||||
let mut all_names: Vec<_> = signature.args.iter().map(|v| (v.name, v.ty)).rev().collect();
|
let mut all_names: Vec<_> = signature.args.iter().map(|v| (v.name, v.ty)).rev().collect();
|
||||||
for (i, t) in posargs.iter().enumerate() {
|
for (i, t) in posargs.iter().enumerate() {
|
||||||
if signature.args.len() <= i {
|
if signature.args.len() <= i {
|
||||||
|
self.restore_snapshot();
|
||||||
return Err(TypeError::new(
|
return Err(TypeError::new(
|
||||||
TypeErrorKind::TooManyArguments { expected: signature.args.len(), got: i },
|
TypeErrorKind::TooManyArguments { expected: signature.args.len(), got: i },
|
||||||
*loc,
|
*loc,
|
||||||
@ -483,6 +484,7 @@ impl Unifier {
|
|||||||
}
|
}
|
||||||
self.unify_cache.clear();
|
self.unify_cache.clear();
|
||||||
if self.unification_table.unioned(a, b) {
|
if self.unification_table.unioned(a, b) {
|
||||||
|
self.discard_snapshot(snapshot);
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
let result = self.unify_impl(a, b, false);
|
let result = self.unify_impl(a, b, false);
|
||||||
|
@ -61,6 +61,7 @@ impl<V> UnificationTable<V> {
|
|||||||
if self.ranks[a] < self.ranks[b] {
|
if self.ranks[a] < self.ranks[b] {
|
||||||
std::mem::swap(&mut a, &mut b);
|
std::mem::swap(&mut a, &mut b);
|
||||||
}
|
}
|
||||||
|
self.log.push(Action::Parent { key: b, original_parent: a });
|
||||||
self.parents[b] = a;
|
self.parents[b] = a;
|
||||||
if self.ranks[a] == self.ranks[b] {
|
if self.ranks[a] == self.ranks[b] {
|
||||||
self.log.push(Action::Rank { key: a, original_rank: self.ranks[a] });
|
self.log.push(Action::Rank { key: a, original_rank: self.ranks[a] });
|
||||||
|
Loading…
Reference in New Issue
Block a user