mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge pull request #3835 from roc-lang/ext-vars-in-derivers
Support bound and unbound extension variables in deriving
This commit is contained in:
commit
acb71d6007
11 changed files with 202 additions and 61 deletions
|
@ -2728,7 +2728,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)
|
||||
|
@ -3369,9 +3369,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),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue