correct wrong early return

This commit is contained in:
Brendan Hansknecht 2023-04-07 19:07:16 -07:00
parent 030597c59a
commit 8dd9a5e3c7
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -1794,36 +1794,40 @@ fn solve(
) {
// List U8 always valid.
subs.rollback_to(snapshot);
return state;
}
subs.rollback_to(snapshot);
state
} else {
subs.rollback_to(snapshot);
let snapshot = subs.snapshot();
// We explicitly match on the last unify to get the type in the case it errors.
match unify(
&mut UEnv::new(subs),
actual,
Variable::STR,
Mode::EQ,
Polarity::OF_VALUE,
) {
Success { .. } => {
// Str only valid if valid utf8.
if let Err(err) = std::str::from_utf8(bytes) {
let problem = TypeError::IngestedFileBadUtf8(file_path.clone(), err);
problems.push(problem);
let snapshot = subs.snapshot();
// We explicitly match on the last unify to get the type in the case it errors.
match unify(
&mut UEnv::new(subs),
actual,
Variable::STR,
Mode::EQ,
Polarity::OF_VALUE,
) {
Success { .. } => {
// Str only valid if valid utf8.
if let Err(err) = std::str::from_utf8(bytes) {
let problem =
TypeError::IngestedFileBadUtf8(file_path.clone(), err);
problems.push(problem);
}
subs.rollback_to(snapshot);
state
}
Failure(_, actual_type, _, _) => {
subs.rollback_to(snapshot);
subs.rollback_to(snapshot);
state
}
Failure(_, actual_type, _, _) => {
subs.rollback_to(snapshot);
let problem =
TypeError::IngestedFileUnsupportedType(file_path.clone(), actual_type);
problems.push(problem);
state
let problem = TypeError::IngestedFileUnsupportedType(
file_path.clone(),
actual_type,
);
problems.push(problem);
state
}
}
}
}