mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
exhaustive expects type index
This commit is contained in:
parent
c4016547af
commit
cbade622b6
@ -615,8 +615,8 @@ impl Constraints {
|
||||
real_var: Variable,
|
||||
real_region: Region,
|
||||
category_and_expectation: Result<
|
||||
(Category, Expected<Type>),
|
||||
(PatternCategory, PExpected<Type>),
|
||||
(Category, ExpectedTypeIndex),
|
||||
(PatternCategory, PExpectedTypeIndex),
|
||||
>,
|
||||
sketched_rows: SketchedRows,
|
||||
context: ExhaustiveContext,
|
||||
@ -628,15 +628,12 @@ impl Constraints {
|
||||
let equality = match category_and_expectation {
|
||||
Ok((category, expected)) => {
|
||||
let category = Index::push_new(&mut self.categories, category);
|
||||
let expected = Index::push_new(&mut self.expectations, expected.map(Cell::new));
|
||||
let equality = Eq(real_var, expected, category, real_region);
|
||||
let equality = Index::push_new(&mut self.eq, equality);
|
||||
Ok(equality)
|
||||
}
|
||||
Err((category, expected)) => {
|
||||
let category = Index::push_new(&mut self.pattern_categories, category);
|
||||
let expected =
|
||||
Index::push_new(&mut self.pattern_expectations, expected.map(Cell::new));
|
||||
let equality = PatternEq(real_var, expected, category, real_region);
|
||||
let equality = Index::push_new(&mut self.pattern_eq, equality);
|
||||
Err(equality)
|
||||
|
@ -902,13 +902,15 @@ pub fn constrain_expr(
|
||||
|
||||
// Now check the condition against the type expected by the branches.
|
||||
let sketched_rows = sketch_when_branches(branches_region, branches);
|
||||
let expected_by_branches = constraints.push_expected_type(Expected::ForReason(
|
||||
Reason::WhenBranches,
|
||||
branches_cond_type,
|
||||
branches_region,
|
||||
));
|
||||
let cond_matches_branches_constraint = constraints.exhaustive(
|
||||
real_cond_var,
|
||||
loc_cond.region,
|
||||
Ok((
|
||||
loc_cond.value.category(),
|
||||
Expected::ForReason(Reason::WhenBranches, branches_cond_type, branches_region),
|
||||
)),
|
||||
Ok((loc_cond.value.category(), expected_by_branches)),
|
||||
sketched_rows,
|
||||
ExhaustiveContext::BadCase,
|
||||
*exhaustive,
|
||||
@ -2562,14 +2564,14 @@ fn constrain_typed_function_arguments(
|
||||
// annotation wants.
|
||||
let sketched_rows = sketch_pattern_to_rows(loc_pattern.region, &loc_pattern.value);
|
||||
let category = loc_pattern.value.category();
|
||||
let expected = PExpected::ForReason(
|
||||
let expected = constraints.push_pat_expected_type(PExpected::ForReason(
|
||||
PReason::TypedArg {
|
||||
index: HumanIndex::zero_based(index),
|
||||
opt_name: opt_label,
|
||||
},
|
||||
Type::Variable(*pattern_var),
|
||||
loc_pattern.region,
|
||||
);
|
||||
));
|
||||
let exhaustive_constraint = constraints.exhaustive(
|
||||
annotation_var,
|
||||
loc_pattern.region,
|
||||
@ -2677,14 +2679,14 @@ fn constrain_typed_function_arguments_simple(
|
||||
// annotation wants.
|
||||
let sketched_rows = sketch_pattern_to_rows(loc_pattern.region, &loc_pattern.value);
|
||||
let category = loc_pattern.value.category();
|
||||
let expected = PExpected::ForReason(
|
||||
let expected = constraints.push_pat_expected_type(PExpected::ForReason(
|
||||
PReason::TypedArg {
|
||||
index: HumanIndex::zero_based(index),
|
||||
opt_name: Some(symbol),
|
||||
},
|
||||
Type::Variable(*pattern_var),
|
||||
loc_pattern.region,
|
||||
);
|
||||
));
|
||||
let exhaustive_constraint = constraints.exhaustive(
|
||||
annotation_var,
|
||||
loc_pattern.region,
|
||||
|
Loading…
Reference in New Issue
Block a user