mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Include error vars in is_recursion_var checks
This commit is contained in:
parent
bef9b54124
commit
735685dd86
2 changed files with 16 additions and 2 deletions
|
@ -2150,6 +2150,18 @@ impl Subs {
|
||||||
pub fn dbg(&self, var: Variable) -> impl std::fmt::Debug + '_ {
|
pub fn dbg(&self, var: Variable) -> impl std::fmt::Debug + '_ {
|
||||||
SubsFmtContent(self.get_content_without_compacting(var), self)
|
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)]
|
#[inline(always)]
|
||||||
|
|
|
@ -2807,7 +2807,7 @@ fn unify_shared_tags_merge_new<M: MetaCollector>(
|
||||||
let flat_type = match recursion_var {
|
let flat_type = match recursion_var {
|
||||||
Rec::None => FlatType::TagUnion(new_tags, new_ext_var),
|
Rec::None => FlatType::TagUnion(new_tags, new_ext_var),
|
||||||
Rec::Left(rec) | Rec::Right(rec) | Rec::Both(rec, _) => {
|
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)
|
FlatType::RecursiveTagUnion(rec, new_tags, new_ext_var)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3494,7 +3494,9 @@ fn is_recursion_var(subs: &Subs, var: Variable) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
subs.get_content_without_compacting(var),
|
subs.get_content_without_compacting(var),
|
||||||
Content::RecursionVar { .. }
|
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)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue