mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-24 20:42:29 +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
|
@ -422,12 +422,13 @@ pub fn constrain_expr(
|
|||
constraints.lookup(*symbol, expected, region)
|
||||
}
|
||||
&AbilityMember(symbol, specialization_id, specialization_var) => {
|
||||
// make lookup constraint to lookup this symbol's type in the environment
|
||||
let store_expected = constraints.equal_types_var(
|
||||
// Save the expectation in the `specialization_var` so we know what to specialize, then
|
||||
// lookup the member in the environment.
|
||||
let store_expected = constraints.store(
|
||||
expected.get_type_ref().clone(),
|
||||
specialization_var,
|
||||
expected,
|
||||
Category::Storage(file!(), line!()),
|
||||
region,
|
||||
file!(),
|
||||
line!(),
|
||||
);
|
||||
let lookup_constr = constraints.lookup(
|
||||
symbol,
|
||||
|
@ -435,7 +436,7 @@ pub fn constrain_expr(
|
|||
region,
|
||||
);
|
||||
|
||||
// Make sure we attempt to resolve the specialization, if we need to.
|
||||
// Make sure we attempt to resolve the specialization, if we can.
|
||||
if let Some(specialization_id) = specialization_id {
|
||||
env.resolutions_to_make.push(OpportunisticResolve {
|
||||
specialization_variable: specialization_var,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue