mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge pull request #4556 from roc-lang/fix-fixpoint-fixing
Correct when fixpoint-fixed type variables can be reunified
This commit is contained in:
commit
ef5d83a42d
3 changed files with 80 additions and 2 deletions
|
@ -8283,4 +8283,41 @@ mod solve_expr {
|
||||||
"MDict v -> MDict v | v has Eq",
|
"MDict v -> MDict v | v has Eq",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unify_types_with_fixed_fixpoints_outside_fixing_region() {
|
||||||
|
infer_queries!(indoc!(
|
||||||
|
r#"
|
||||||
|
app "test" provides [main] to "./platform"
|
||||||
|
|
||||||
|
Input := [
|
||||||
|
FromJob Job
|
||||||
|
]
|
||||||
|
|
||||||
|
Job := [
|
||||||
|
Job (List Input)
|
||||||
|
]
|
||||||
|
|
||||||
|
job : List Input -> Job
|
||||||
|
job = \inputs ->
|
||||||
|
@Job (Job inputs)
|
||||||
|
|
||||||
|
helloWorld : Job
|
||||||
|
helloWorld =
|
||||||
|
@Job ( Job [ @Input (FromJob greeting) ] )
|
||||||
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
greeting : Job
|
||||||
|
greeting =
|
||||||
|
job []
|
||||||
|
|
||||||
|
main = (\_ -> "Which platform am I running on now?\n") helloWorld
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
@r###"
|
||||||
|
@Input (FromJob greeting) : [FromJob ([Job (List [FromJob a])] as a)]
|
||||||
|
"###
|
||||||
|
print_only_under_alias: true
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2047,3 +2047,39 @@ fn issue_4077_fixed_fixpoint() {
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
fn unify_types_with_fixed_fixpoints_outside_fixing_region() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
app "test" provides [main] to "./platform"
|
||||||
|
|
||||||
|
Input := [
|
||||||
|
FromJob Job (List Str),
|
||||||
|
]
|
||||||
|
|
||||||
|
Job := [
|
||||||
|
Job (List Input)
|
||||||
|
]
|
||||||
|
|
||||||
|
job : List Input -> Job
|
||||||
|
job = \inputs ->
|
||||||
|
@Job (Job inputs)
|
||||||
|
|
||||||
|
helloWorld : Job
|
||||||
|
helloWorld =
|
||||||
|
@Job ( Job [ @Input (FromJob greeting []) ] )
|
||||||
|
|
||||||
|
greeting : Job
|
||||||
|
greeting =
|
||||||
|
job []
|
||||||
|
|
||||||
|
main = (\_ -> "OKAY") helloWorld
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
RocStr::from("OKAY"),
|
||||||
|
RocStr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -2814,8 +2814,13 @@ fn unify_shared_tags_merge_new<M: MetaCollector>(
|
||||||
new_ext_var: Variable,
|
new_ext_var: Variable,
|
||||||
recursion_var: Rec,
|
recursion_var: Rec,
|
||||||
) -> Outcome<M> {
|
) -> Outcome<M> {
|
||||||
let was_fixed = env.was_fixed(ctx.first) || env.was_fixed(ctx.second);
|
if env.was_fixed(ctx.first) && env.was_fixed(ctx.second) {
|
||||||
if was_fixed {
|
// Both of the tags we're looking at were just involved in fixpoint-fixing, so their types
|
||||||
|
// should be aligned. As such, do not attempt to unify them and update the recursion
|
||||||
|
// pointer again.
|
||||||
|
debug_assert!(env
|
||||||
|
.subs
|
||||||
|
.equivalent_without_compacting(ctx.first, ctx.second));
|
||||||
return Default::default();
|
return Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue