Content variant ErasedLambda

This commit is contained in:
Ayaz Hafiz 2023-06-23 15:53:08 -05:00
parent c459757062
commit 6e5a308557
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
20 changed files with 147 additions and 93 deletions

View file

@ -827,6 +827,12 @@ trait DerivableVisitor {
context: NotDerivableContext::NoContext,
})
}
ErasedLambda => {
return Err(NotDerivable {
var,
context: NotDerivableContext::NoContext,
})
}
Error => {
return Err(NotDerivable {
var,

View file

@ -262,7 +262,7 @@ fn deep_copy_var_help(
subs.set_content_unchecked(copy, Structure(new_flat_type));
}
FlexVar(_) | FlexAbleVar(_, _) | Error => {
FlexVar(_) | FlexAbleVar(_, _) | Error | ErasedLambda => {
subs.set_content_unchecked(copy, content);
}

View file

@ -2356,6 +2356,8 @@ fn adjust_rank_content(
rank
}
ErasedLambda => group_rank,
RangedNumber(_) => group_rank,
}
}

View file

@ -690,6 +690,7 @@ fn make_specialization_decision<P: Phase>(
| FlexVar(..)
| RigidVar(..)
| LambdaSet(..)
| ErasedLambda
| RangedNumber(..) => {
internal_error!("unexpected")
}

View file

@ -70,7 +70,8 @@ pub(crate) fn either_type_index_to_var(
|| matches!(
types[type_index],
TypeTag::EmptyRecord | TypeTag::EmptyTagUnion
)
),
"different variable was returned for type index variable cell!"
);
var
}
@ -346,29 +347,29 @@ pub(crate) fn type_to_var_help(
name,
ambient_function,
} => {
let union_lambdas = match env.function_kind {
match env.function_kind {
FunctionKind::LambdaSet => {
let captures = types.get_type_arguments(typ_index);
create_union_lambda(env, rank, arena, types, name, captures, &mut stack)
let union_lambdas = create_union_lambda(
env, rank, arena, types, name, captures, &mut stack,
);
let content = Content::LambdaSet(subs::LambdaSet {
solved: union_lambdas,
// We may figure out the lambda set is recursive during solving, but it never
// is to begin with.
recursion_var: OptVariable::NONE,
unspecialized: SubsSlice::default(),
ambient_function,
});
env.register_with_known_var(destination, rank, content)
}
FunctionKind::Erased => {
// NB we cannot use a constant variable for the erased lambda set (yet)
// because we still need to link it to the ambient function. In the future,
// perhaps we could.
UnionLambdas::from_tag_name_index(Subs::LAMBDA_NAME_ERASED_INDEX)
// TODO(erased-lambda): can we merge in with Variable::ERASED_LAMBDA instead?
env.register_with_known_var(destination, rank, Content::ErasedLambda)
}
};
let content = Content::LambdaSet(subs::LambdaSet {
solved: union_lambdas,
// We may figure out the lambda set is recursive during solving, but it never
// is to begin with.
recursion_var: OptVariable::NONE,
unspecialized: SubsSlice::default(),
ambient_function,
});
env.register_with_known_var(destination, rank, content)
}
}
UnspecializedLambdaSet { unspecialized } => {
let unspecialized_slice = SubsSlice::extend_new(