mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
parent
2cc9c32c37
commit
ce160f28a2
2 changed files with 29 additions and 2 deletions
|
@ -8197,4 +8197,27 @@ mod solve_expr {
|
|||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fix_recursion_under_alias_issue_4368() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [doIt] to "./platform"
|
||||
|
||||
Effect : [
|
||||
DoIt {} ({} -> Effect),
|
||||
]
|
||||
|
||||
Task := ({} -> Effect) -> Effect
|
||||
|
||||
doIt : {} -> Task
|
||||
doIt = \{} ->
|
||||
@Task \toNext ->
|
||||
DoIt {} \{} -> (toNext {})
|
||||
"#
|
||||
),
|
||||
"{} -> Task",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3255,13 +3255,17 @@ fn occurs(
|
|||
EmptyRecord | EmptyTagUnion => Ok(()),
|
||||
}
|
||||
}
|
||||
Alias(_, args, _, _) => {
|
||||
Alias(_, args, real_var, _) => {
|
||||
let mut new_seen = seen.to_owned();
|
||||
new_seen.push(root_var);
|
||||
|
||||
for var_index in args.into_iter() {
|
||||
let var = subs[var_index];
|
||||
short_circuit_help(subs, root_var, &new_seen, var)?;
|
||||
if short_circuit_help(subs, root_var, &new_seen, var).is_err() {
|
||||
// Pay the cost and figure out what the actual recursion point is
|
||||
|
||||
return short_circuit_help(subs, root_var, &new_seen, *real_var);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue