mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
Include error vars in is_recursion_var checks
This commit is contained in:
parent
bef9b54124
commit
735685dd86
@ -2150,6 +2150,18 @@ impl Subs {
|
||||
pub fn dbg(&self, var: Variable) -> impl std::fmt::Debug + '_ {
|
||||
SubsFmtContent(self.get_content_without_compacting(var), self)
|
||||
}
|
||||
|
||||
/// Is this variable involved in an error?
|
||||
pub fn is_error_var(&self, var: Variable) -> bool {
|
||||
match self.get_content_without_compacting(var) {
|
||||
Content::Error => true,
|
||||
Content::FlexVar(Some(index)) => {
|
||||
// Generated names for errors start with `#`
|
||||
self[*index].as_str().starts_with('#')
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -2807,7 +2807,7 @@ fn unify_shared_tags_merge_new<M: MetaCollector>(
|
||||
let flat_type = match recursion_var {
|
||||
Rec::None => FlatType::TagUnion(new_tags, new_ext_var),
|
||||
Rec::Left(rec) | Rec::Right(rec) | Rec::Both(rec, _) => {
|
||||
debug_assert!(is_recursion_var(env.subs, rec));
|
||||
debug_assert!(is_recursion_var(env.subs, rec), "{:?}", env.subs.dbg(rec));
|
||||
FlatType::RecursiveTagUnion(rec, new_tags, new_ext_var)
|
||||
}
|
||||
};
|
||||
@ -3494,7 +3494,9 @@ fn is_recursion_var(subs: &Subs, var: Variable) -> bool {
|
||||
matches!(
|
||||
subs.get_content_without_compacting(var),
|
||||
Content::RecursionVar { .. }
|
||||
)
|
||||
) ||
|
||||
// Error-like vars should always unify, so pretend they are recursion vars too.
|
||||
subs.is_error_var(var)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
Loading…
Reference in New Issue
Block a user