mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-11 22:36:18 +00:00
When storing variables, merge them directly with the target rather than unifying
When we unify two variables that end up merged, the rank of the resulting content is the lower of the two variables being merged. But during storage, we really do mean, take the target descriptor of the type we're merging against, and don't try to lower to a possibly-generalized rank! This fixes a couple bugs I didn't even realize were present!
This commit is contained in:
parent
5f115685e4
commit
4657a957f7
4 changed files with 106 additions and 59 deletions
|
@ -928,51 +928,10 @@ fn solve(
|
|||
aliases,
|
||||
*source_index,
|
||||
);
|
||||
let target = *target;
|
||||
|
||||
match unify(&mut UEnv::new(subs), actual, target, Mode::EQ) {
|
||||
Success {
|
||||
vars,
|
||||
// ERROR NOT REPORTED
|
||||
must_implement_ability: _,
|
||||
lambda_sets_to_specialize,
|
||||
extra_metadata: _,
|
||||
} => {
|
||||
introduce(subs, rank, pools, &vars);
|
||||
|
||||
let CompactionResult {
|
||||
obligations,
|
||||
awaiting_specialization,
|
||||
} = compact_lambda_sets_of_vars(
|
||||
subs,
|
||||
derived_env,
|
||||
arena,
|
||||
pools,
|
||||
lambda_sets_to_specialize,
|
||||
&SolvePhase { abilities_store },
|
||||
);
|
||||
// implement obligations not reported
|
||||
_ = obligations;
|
||||
// but awaited specializations must be recorded
|
||||
awaiting_specializations.union(awaiting_specialization);
|
||||
|
||||
state
|
||||
}
|
||||
Failure(vars, _actual_type, _expected_type, _bad_impls) => {
|
||||
introduce(subs, rank, pools, &vars);
|
||||
|
||||
// ERROR NOT REPORTED
|
||||
|
||||
state
|
||||
}
|
||||
BadType(vars, _) => {
|
||||
introduce(subs, rank, pools, &vars);
|
||||
|
||||
// ERROR NOT REPORTED
|
||||
|
||||
state
|
||||
}
|
||||
}
|
||||
let actual_desc = subs.get(actual);
|
||||
subs.union(*target, actual, actual_desc);
|
||||
state
|
||||
}
|
||||
Lookup(symbol, expectation_index, region) => {
|
||||
match env.get_var_by_symbol(symbol) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue