Support derivers for tag unions with ext vars

This commit is contained in:
Ayaz Hafiz 2022-08-17 10:15:05 -05:00
parent 2f24c81dab
commit a8bd529664
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
6 changed files with 30 additions and 13 deletions

View file

@ -2610,7 +2610,7 @@ pub fn union_sorted_tags<'a>(
// x = A
// x
// In such cases it's fine to drop the variable. We may be proven wrong in the future...
| Err((_, Content::FlexVar(_) | Content::RigidVar(_)))
| Err((_, Content::FlexVar(_) | Content::FlexAbleVar(..) | Content::RigidVar(_) | Content::RigidAbleVar(..)))
| Err((_, Content::RecursionVar { .. })) => {
let opt_rec_var = get_recursion_var(subs, var);
union_sorted_tags_help(arena, tags_vec, opt_rec_var, subs, target_info)
@ -3251,9 +3251,17 @@ pub fn ext_var_is_empty_tag_union(subs: &Subs, ext_var: Variable) -> bool {
// the ext_var is empty
let mut ext_fields = std::vec::Vec::new();
match roc_types::pretty_print::chase_ext_tag_union(subs, ext_var, &mut ext_fields) {
Ok(()) | Err((_, Content::FlexVar(_) | Content::RigidVar(_) | Content::Error)) => {
ext_fields.is_empty()
}
Ok(())
| Err((
_,
// Allow flex/rigid to decay away into nothing
Content::FlexVar(_)
| Content::FlexAbleVar(..)
| Content::RigidVar(_)
| Content::RigidAbleVar(..)
// So that we can continue compiling in the presence of errors
| Content::Error,
)) => ext_fields.is_empty(),
Err(content) => panic!("invalid content in ext_var: {:?}", content),
}
}