mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Remove when-related changes
This commit is contained in:
parent
b5efd830e5
commit
c67bc5a8d6
3 changed files with 20 additions and 63 deletions
|
@ -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 =
|
||||
|expected: &Expected<Type>, index, branch_region| match expected {
|
||||
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) =
|
||||
constrain_when_branch_help(
|
||||
constraints,
|
||||
|
|
|
@ -6251,7 +6251,7 @@ mod solve_expr {
|
|||
|
||||
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
|
||||
hash = \$Id n -> n
|
||||
|
@ -6261,7 +6261,7 @@ mod solve_expr {
|
|||
intoHash = \$User id, _ -> id
|
||||
#^^^^^^^^{-1}
|
||||
|
||||
result = hash (intoHash ($User ($Id 123)) ($Id 1))
|
||||
result = hash (intoHash ($User ($Id 123)))
|
||||
# ^^^^ ^^^^^^^^
|
||||
"#
|
||||
),
|
||||
|
|
|
@ -2662,24 +2662,16 @@ mod test_reporting {
|
|||
r#"
|
||||
── 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
|
||||
5│ Red -> 3
|
||||
5│> Red -> 3
|
||||
|
||||
This `x` value is a:
|
||||
Other possibilities include:
|
||||
|
||||
[ Green, Red ]
|
||||
Green
|
||||
|
||||
But the branch patterns have type:
|
||||
|
||||
[ 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 `_`?
|
||||
I would have to crash if I saw one of those! Add branches for them!
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
@ -2702,25 +2694,17 @@ mod test_reporting {
|
|||
r#"
|
||||
── 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
|
||||
5│ Red -> 0
|
||||
6│ Green -> 1
|
||||
5│> Red -> 0
|
||||
6│> Green -> 1
|
||||
|
||||
This `x` value is a:
|
||||
Other possibilities include:
|
||||
|
||||
[ Blue, Green, Red ]
|
||||
Blue
|
||||
|
||||
But the branch patterns have type:
|
||||
|
||||
[ 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 `_`?
|
||||
I would have to crash if I saw one of those! Add branches for them!
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
@ -2743,25 +2727,18 @@ mod test_reporting {
|
|||
r#"
|
||||
── 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
|
||||
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:
|
||||
|
||||
[ 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 `_`?
|
||||
I would have to crash if I saw one of those! Add branches for them!
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue