Merge pull request #5203 from roc-lang/virtual-dom-annotations

Fix a few bugs Virtual-DOM cropped up
This commit is contained in:
Ayaz 2023-03-25 20:00:51 -05:00 committed by GitHub
commit 8c55e8126d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 14 deletions

View file

@ -3921,7 +3921,23 @@ fn adjust_rank_content(
Alias(_, args, real_var, _) => {
let mut rank = Rank::toplevel();
for var_index in args.all_variables() {
// Avoid visiting lambda set variables stored in the type variables of the alias
// independently.
//
// Why? Lambda set variables on the alias are not truly type arguments to the alias,
// and instead are links to the lambda sets that appear in functions under the real
// type of the alias. If their ranks are adjusted independently, we end up looking at
// function types "inside-out" - when the whole point of rank-adjustment is to look
// from the outside-in to determine at what rank a type lies!
//
// So, just wait to adjust their ranks until we visit the function types that contain
// them. If they should be generalized (or pulled to a lower rank) that will happen
// then; otherwise, we risk generalizing a lambda set too early, when its enclosing
// function type should not be.
let adjustable_variables =
(args.type_variables().into_iter()).chain(args.infer_ext_in_output_variables());
for var_index in adjustable_variables {
let var = subs[var_index];
rank = rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, var));
}