Handle recursion through Applys with errors

Closes #219
This commit is contained in:
Ayaz Hafiz 2022-05-10 12:58:14 -04:00
parent 4339d50480
commit 62ebb80f09
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 96 additions and 1 deletions

View file

@ -1358,7 +1358,17 @@ fn maybe_mark_tag_union_recursive(subs: &mut Subs, tag_union_var: Variable) {
}
}
panic!("recursive loop does not contain a tag union")
// Might not be any tag union if we only pass through `Apply`s. Otherwise, we have a bug!
if chain.iter().all(|&v| {
matches!(
subs.get_content_without_compacting(v),
Content::Structure(FlatType::Apply(..))
)
}) {
return;
} else {
internal_error!("recursive loop does not contain a tag union")
}
}
}
}