mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
make sure lambda sets within aliases are in IntroducedVariables
This commit is contained in:
parent
012a2d07a6
commit
6370a80c62
2 changed files with 27 additions and 0 deletions
|
@ -340,6 +340,7 @@ fn can_annotation_help(
|
||||||
let (type_arguments, lambda_set_variables, actual) =
|
let (type_arguments, lambda_set_variables, actual) =
|
||||||
instantiate_and_freshen_alias_type(
|
instantiate_and_freshen_alias_type(
|
||||||
var_store,
|
var_store,
|
||||||
|
introduced_variables,
|
||||||
&alias.type_variables,
|
&alias.type_variables,
|
||||||
args,
|
args,
|
||||||
&alias.lambda_set_variables,
|
&alias.lambda_set_variables,
|
||||||
|
@ -645,6 +646,7 @@ fn can_annotation_help(
|
||||||
|
|
||||||
pub fn instantiate_and_freshen_alias_type(
|
pub fn instantiate_and_freshen_alias_type(
|
||||||
var_store: &mut VarStore,
|
var_store: &mut VarStore,
|
||||||
|
introduced_variables: &mut IntroducedVariables,
|
||||||
type_variables: &[Loc<(Lowercase, Variable)>],
|
type_variables: &[Loc<(Lowercase, Variable)>],
|
||||||
type_arguments: Vec<Type>,
|
type_arguments: Vec<Type>,
|
||||||
lambda_set_variables: &[LambdaSet],
|
lambda_set_variables: &[LambdaSet],
|
||||||
|
@ -674,6 +676,7 @@ pub fn instantiate_and_freshen_alias_type(
|
||||||
if let Type::Variable(var) = typ.0 {
|
if let Type::Variable(var) = typ.0 {
|
||||||
let fresh = var_store.fresh();
|
let fresh = var_store.fresh();
|
||||||
substitutions.insert(var, Type::Variable(fresh));
|
substitutions.insert(var, Type::Variable(fresh));
|
||||||
|
introduced_variables.insert_lambda_set(fresh);
|
||||||
new_lambda_set_variables.push(LambdaSet(Type::Variable(fresh)));
|
new_lambda_set_variables.push(LambdaSet(Type::Variable(fresh)));
|
||||||
} else {
|
} else {
|
||||||
unreachable!("at this point there should be only vars in there");
|
unreachable!("at this point there should be only vars in there");
|
||||||
|
@ -698,8 +701,12 @@ pub fn freshen_opaque_def(
|
||||||
.map(|_| Type::Variable(var_store.fresh()))
|
.map(|_| Type::Variable(var_store.fresh()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
// TODO this gets ignored; is that a problem
|
||||||
|
let mut introduced_variables = IntroducedVariables::default();
|
||||||
|
|
||||||
instantiate_and_freshen_alias_type(
|
instantiate_and_freshen_alias_type(
|
||||||
var_store,
|
var_store,
|
||||||
|
&mut introduced_variables,
|
||||||
&opaque.type_variables,
|
&opaque.type_variables,
|
||||||
fresh_arguments,
|
fresh_arguments,
|
||||||
&opaque.lambda_set_variables,
|
&opaque.lambda_set_variables,
|
||||||
|
|
|
@ -5509,4 +5509,24 @@ mod solve_expr {
|
||||||
r#"Id [ A, B, C { a : Str }e ] -> Str"#,
|
r#"Id [ A, B, C { a : Str }e ] -> Str"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn lambda_set_within_alias_is_quantified() {
|
||||||
|
infer_eq_without_problem(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test" provides [ effectAlways ] to "./platform"
|
||||||
|
|
||||||
|
Effect a : [ @Effect ({} -> a) ]
|
||||||
|
|
||||||
|
effectAlways : a -> Effect a
|
||||||
|
effectAlways = \x ->
|
||||||
|
inner = \{} -> x
|
||||||
|
|
||||||
|
@Effect inner
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
r#"a -> Effect [ inner a ]*"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue