mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
not so fast
This commit is contained in:
parent
564efd528a
commit
6ab90cd15d
2 changed files with 14 additions and 7 deletions
|
@ -585,7 +585,7 @@ pub fn chase_ext_tag_union(
|
||||||
fields: &mut Vec<(TagName, Vec<Variable>)>,
|
fields: &mut Vec<(TagName, Vec<Variable>)>,
|
||||||
) -> Result<(), (Variable, Content)> {
|
) -> Result<(), (Variable, Content)> {
|
||||||
use FlatType::*;
|
use FlatType::*;
|
||||||
match subs.get_without_compacting(var).content {
|
match subs.get_content_without_compacting(var) {
|
||||||
Content::Structure(EmptyTagUnion) => Ok(()),
|
Content::Structure(EmptyTagUnion) => Ok(()),
|
||||||
Content::Structure(TagUnion(tags, ext_var))
|
Content::Structure(TagUnion(tags, ext_var))
|
||||||
| Content::Structure(RecursiveTagUnion(_, tags, ext_var)) => {
|
| Content::Structure(RecursiveTagUnion(_, tags, ext_var)) => {
|
||||||
|
@ -593,16 +593,16 @@ pub fn chase_ext_tag_union(
|
||||||
fields.push((label.clone(), vars.to_vec()));
|
fields.push((label.clone(), vars.to_vec()));
|
||||||
}
|
}
|
||||||
|
|
||||||
chase_ext_tag_union(subs, ext_var, fields)
|
chase_ext_tag_union(subs, *ext_var, fields)
|
||||||
}
|
}
|
||||||
Content::Structure(FunctionOrTagUnion(tag_name, _, ext_var)) => {
|
Content::Structure(FunctionOrTagUnion(tag_name, _, ext_var)) => {
|
||||||
fields.push((tag_name, vec![]));
|
fields.push((tag_name.clone(), vec![]));
|
||||||
|
|
||||||
chase_ext_tag_union(subs, ext_var, fields)
|
chase_ext_tag_union(subs, *ext_var, fields)
|
||||||
}
|
}
|
||||||
Content::Alias(_, _, var) => chase_ext_tag_union(subs, var, fields),
|
Content::Alias(_, _, var) => chase_ext_tag_union(subs, *var, fields),
|
||||||
|
|
||||||
content => Err((var, content)),
|
content => Err((var, content.clone())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,14 @@ fn unify_tag_union(
|
||||||
(Some(v1), Some(_v2)) => Some(v1),
|
(Some(v1), Some(_v2)) => Some(v1),
|
||||||
};
|
};
|
||||||
|
|
||||||
if tags1.len() == 1 && tags2.len() == 1 && tags1 == tags2 {
|
// heuristic: our closure defunctionalization scheme generates a bunch of one-tag unions
|
||||||
|
// also our number types fall in this category too.
|
||||||
|
if tags1.len() == 1
|
||||||
|
&& tags2.len() == 1
|
||||||
|
&& tags1 == tags2
|
||||||
|
&& subs.get_content_without_compacting(rec1.ext)
|
||||||
|
== subs.get_content_without_compacting(rec2.ext)
|
||||||
|
{
|
||||||
return unify_shared_tags_merge(subs, ctx, tags1, rec1.ext, recursion_var);
|
return unify_shared_tags_merge(subs, ctx, tags1, rec1.ext, recursion_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue