Remove when-related changes

This commit is contained in:
Ayaz Hafiz 2022-05-04 09:39:50 -04:00 committed by ayazhafiz
parent b5efd830e5
commit c67bc5a8d6
3 changed files with 20 additions and 63 deletions

View file

@ -606,15 +606,6 @@ pub fn constrain_expr(
) )
}; };
let branches_region = {
debug_assert!(!branches.is_empty());
Region::span_across(
&loc_cond.region,
// &branches.first().unwrap().region(),
&branches.last().unwrap().region(),
)
};
let branch_expr_reason = let branch_expr_reason =
|expected: &Expected<Type>, index, branch_region| match expected { |expected: &Expected<Type>, index, branch_region| match expected {
FromAnnotation(name, arity, ann_source, _typ) => { FromAnnotation(name, arity, ann_source, _typ) => {
@ -678,17 +669,6 @@ pub fn constrain_expr(
) )
}; };
let expected_pattern = |sub_pattern| {
PExpected::ForReason(
PReason::WhenMatch {
index: HumanIndex::zero_based(index),
sub_pattern,
},
cond_type.clone(),
pattern_region,
)
};
let (new_pattern_vars, new_pattern_headers, pattern_con, branch_con) = let (new_pattern_vars, new_pattern_headers, pattern_con, branch_con) =
constrain_when_branch_help( constrain_when_branch_help(
constraints, constraints,

View file

@ -6251,7 +6251,7 @@ mod solve_expr {
Hash has hash : a -> U64 | a has Hash Hash has hash : a -> U64 | a has Hash
IntoHash has intoHash : a, b -> b | a has IntoHash, b has Hash IntoHash has intoHash : a -> b | a has IntoHash, b has Hash
Id := U64 Id := U64
hash = \$Id n -> n hash = \$Id n -> n
@ -6261,7 +6261,7 @@ mod solve_expr {
intoHash = \$User id, _ -> id intoHash = \$User id, _ -> id
#^^^^^^^^{-1} #^^^^^^^^{-1}
result = hash (intoHash ($User ($Id 123)) ($Id 1)) result = hash (intoHash ($User ($Id 123)))
# ^^^^ ^^^^^^^^ # ^^^^ ^^^^^^^^
"# "#
), ),

View file

@ -2662,24 +2662,16 @@ mod test_reporting {
r#" r#"
UNSAFE PATTERN /code/proj/Main.roc UNSAFE PATTERN /code/proj/Main.roc
The branches of this `when` expression don't match the condition: This `when` does not cover all the possibilities:
4> when x is 4> when x is
5 Red -> 3 5> Red -> 3
This `x` value is a: Other possibilities include:
[ Green, Red ] Green
But the branch patterns have type: I would have to crash if I saw one of those! Add branches for them!
[ Red ]
The branches must be cases of the `when` condition's type!
Tip: Looks like the branches are missing coverage of the `Green` tag.
Tip: Maybe you need to add a catch-all branch, like `_`?
"# "#
), ),
) )
@ -2702,25 +2694,17 @@ mod test_reporting {
r#" r#"
UNSAFE PATTERN /code/proj/Main.roc UNSAFE PATTERN /code/proj/Main.roc
The branches of this `when` expression don't match the condition: This `when` does not cover all the possibilities:
4> when x is 4> when x is
5 Red -> 0 5> Red -> 0
6 Green -> 1 6> Green -> 1
This `x` value is a: Other possibilities include:
[ Blue, Green, Red ] Blue
But the branch patterns have type: I would have to crash if I saw one of those! Add branches for them!
[ Green, Red ]
The branches must be cases of the `when` condition's type!
Tip: Looks like the branches are missing coverage of the `Blue` tag.
Tip: Maybe you need to add a catch-all branch, like `_`?
"# "#
), ),
) )
@ -2743,25 +2727,18 @@ mod test_reporting {
r#" r#"
UNSAFE PATTERN /code/proj/Main.roc UNSAFE PATTERN /code/proj/Main.roc
The branches of this `when` expression don't match the condition: This `when` does not cover all the possibilities:
5> when x is 5> when x is
6 NotAsked -> 3 6> NotAsked -> 3
This `x` value is a: Other possibilities include:
[ Failure I64, Loading, NotAsked, Success Str ] Failure _
Loading
Success _
But the branch patterns have type: I would have to crash if I saw one of those! Add branches for them!
[ NotAsked ]
The branches must be cases of the `when` condition's type!
Tip: Looks like the branches are missing coverage of the
`Success`, `Failure` and `Loading` tags.
Tip: Maybe you need to add a catch-all branch, like `_`?
"# "#
), ),
) )