Merge pull request #4257 from roc-lang/i4246

Correctly check mutual functional recursion between opaque types
This commit is contained in:
Richard Feldman 2022-10-08 16:20:27 -07:00 committed by GitHub
commit 3d5728d82c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View file

@ -1522,8 +1522,9 @@ fn solve(
symbols.iter().any(|(s, _)| {
let var = env.get_var_by_symbol(s).expect("Symbol not solved!");
let content = subs.get_content_without_compacting(var);
!matches!(content, Error | Structure(FlatType::Func(..)))
let (_, underlying_content) = chase_alias_content(subs, var);
!matches!(underlying_content, Error | Structure(FlatType::Func(..)))
})
};
@ -1555,6 +1556,17 @@ fn solve(
state
}
fn chase_alias_content(subs: &Subs, mut var: Variable) -> (Variable, &Content) {
loop {
match subs.get_content_without_compacting(var) {
Content::Alias(_, _, real_var, _) => {
var = *real_var;
}
content => return (var, content),
}
}
}
#[allow(clippy::too_many_arguments)]
fn compact_lambdas_and_check_obligations(
arena: &Bump,