First pass at expectations taking a type index

This commit is contained in:
Ayaz Hafiz 2022-10-25 11:01:53 -05:00
parent 6dc6386f77
commit 2a4fca7034
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
7 changed files with 379 additions and 272 deletions

View file

@ -947,15 +947,16 @@ fn solve(
);
let expectation = &constraints.expectations[expectation_index.index()];
let expected = type_cell_to_var(
let expected = either_type_index_to_var(
constraints,
subs,
rank,
pools,
problems,
abilities_store,
obligation_cache,
pools,
aliases,
expectation.get_type_ref(),
*expectation.get_type_ref(),
);
match unify(
@ -1065,15 +1066,16 @@ fn solve(
let actual = deep_copy_var_in(subs, rank, pools, var, arena);
let expectation = &constraints.expectations[expectation_index.index()];
let expected = type_cell_to_var(
let expected = either_type_index_to_var(
constraints,
subs,
rank,
pools,
problems,
abilities_store,
obligation_cache,
pools,
aliases,
expectation.get_type_ref(),
*expectation.get_type_ref(),
);
match unify(
@ -1487,15 +1489,28 @@ fn solve(
// 4. Condition and branch types aren't "almost equal", this is just a normal type
// error.
let (real_var, real_region, expected_type, category_and_expected) = match eq {
let (real_var, real_region, branches_var, category_and_expected) = match eq {
Ok(eq) => {
let roc_can::constraint::Eq(real_var, expected, category, real_region) =
constraints.eq[eq.index()];
let expected = &constraints.expectations[expected.index()];
let branches_var = either_type_index_to_var(
constraints,
subs,
rank,
pools,
problems,
abilities_store,
obligation_cache,
aliases,
*expected.get_type_ref(),
);
(
real_var,
real_region,
expected.get_type_ref(),
branches_var,
Ok((category, expected)),
)
}
@ -1507,10 +1522,22 @@ fn solve(
real_region,
) = constraints.pattern_eq[peq.index()];
let expected = &constraints.pattern_expectations[expected.index()];
let branches_var = type_cell_to_var(
subs,
rank,
problems,
abilities_store,
obligation_cache,
pools,
aliases,
expected.get_type_ref(),
);
(
real_var,
real_region,
expected.get_type_ref(),
branches_var,
Err((category, expected)),
)
}