mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
First pass at expectations taking a type index
This commit is contained in:
parent
6dc6386f77
commit
2a4fca7034
7 changed files with 379 additions and 272 deletions
|
@ -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)),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue