Correctly introduce new recursion variables at the correct rank

This commit is contained in:
Ayaz Hafiz 2023-04-20 17:30:04 -05:00
parent 7beee4e1f3
commit 5ec2715820
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 56 additions and 12 deletions

View file

@ -2010,22 +2010,35 @@ impl Subs {
result
}
pub fn mark_tag_union_recursive(&mut self, recursive: Variable, tags: UnionTags, ext: TagExt) {
/// Returns the new recursion variable, which should be introduced to the environment as
/// appropriate.
#[must_use]
pub fn mark_tag_union_recursive(
&mut self,
recursive: Variable,
tags: UnionTags,
ext: TagExt,
) -> Variable {
let (rec_var, new_tags) = self.mark_union_recursive_help(recursive, tags);
let new_ext = ext.map(|v| self.explicit_substitute(recursive, rec_var, v));
let flat_type = FlatType::RecursiveTagUnion(rec_var, new_tags, new_ext);
self.set_content(recursive, Content::Structure(flat_type));
rec_var
}
/// Returns the new recursion variable, which should be introduced to the environment as
/// appropriate.
#[must_use]
pub fn mark_lambda_set_recursive(
&mut self,
recursive: Variable,
solved_lambdas: UnionLambdas,
unspecialized_lambdas: SubsSlice<Uls>,
ambient_function_var: Variable,
) {
) -> Variable {
let (rec_var, new_tags) = self.mark_union_recursive_help(recursive, solved_lambdas);
let new_lambda_set = Content::LambdaSet(LambdaSet {
@ -2036,6 +2049,8 @@ impl Subs {
});
self.set_content(recursive, new_lambda_set);
rec_var
}
fn mark_union_recursive_help<L: Label>(