snapshot subs to avoid cloning them

This commit is contained in:
Brendan Hansknecht 2023-04-07 17:04:29 -07:00
parent 90f4885f4b
commit 62fcc71be3
No known key found for this signature in database
GPG Key ID: 0EA784685083E75B

View File

@ -1784,19 +1784,19 @@ fn solve(
*type_index, *type_index,
); );
let snapshot = subs.snapshot();
if let Success { .. } = unify( if let Success { .. } = unify(
// TODO: if we don't clone and a later branch matches, we will get a failure in alias analysis. &mut UEnv::new(subs),
// That said, I assume cloning is expensive and should be avoided.
&mut UEnv::new(&mut subs.clone()),
actual, actual,
Variable::LIST_U8, Variable::LIST_U8,
Mode::EQ, Mode::EQ,
Polarity::OF_VALUE, Polarity::OF_VALUE,
) { ) {
// List U8 always valid. // List U8 always valid.
subs.rollback_to(snapshot);
state state
} else if let Success { .. } = unify( } else if let Success { .. } = unify(
&mut UEnv::new(&mut subs.clone()), &mut UEnv::new(subs),
actual, actual,
Variable::STR, Variable::STR,
Mode::EQ, Mode::EQ,
@ -1807,6 +1807,7 @@ fn solve(
todo!("add type error due to not being a utf8 string"); todo!("add type error due to not being a utf8 string");
} }
subs.rollback_to(snapshot);
state state
} else { } else {
// Unexpected type. // Unexpected type.
@ -1819,6 +1820,7 @@ fn solve(
// ); // );
// problems.push(problem); // problems.push(problem);
// subs.rollback_to(snapshot);
// state // state
} }
} }