Skip to content

Commit 5663468

Browse files
handle binary operators in patterns
Summary: - we did not handle such edge cases previously - fixes T137398643 Reviewed By: VLanvin Differential Revision: D41255663 fbshipit-source-id: 7725717323165a3d833ec31aa9d5818e1c33237a
1 parent 7f307a3 commit 5663468

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

eqwalizer/src/main/scala/com/whatsapp/eqwalizer/tc/ElabPat.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ final class ElabPat(pipelineContext: PipelineContext) {
191191
case _ => (NoneType, env2)
192192
// $COVERAGE-ON$
193193
}
194+
case ">" | "<" | "/=" | ">=" | "=<" | "=/=" | "=:=" | "==" =>
195+
(booleanType, env)
194196
// $COVERAGE-OFF$
195197
case _ => throw UnhandledOp(binOp.pos, op)
196198
// $COVERAGE-ON$

eqwalizer/test_projects/_cli/checkable_funs.cli

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all funs:
2-
All : 2764
3-
Checkable : 2503
4-
Well-typed checkable : 1610
2+
All : 2765
3+
Checkable : 2504
4+
Well-typed checkable : 1611
55
Checkable ratio : 91%
66
Health ratio of checkable : 64%
77
error count : 892
@@ -26,18 +26,18 @@ generated non-test funs:
2626

2727
--------------------------------------------
2828
non-generated funs:
29-
All : 2764
30-
Checkable : 2503
31-
Well-typed checkable : 1610
29+
All : 2765
30+
Checkable : 2504
31+
Well-typed checkable : 1611
3232
Checkable ratio : 91%
3333
Health ratio of checkable : 64%
3434
error count : 892
3535

3636
--------------------------------------------
3737
non-generated non-test funs (most important):
38-
All : 2762
39-
Checkable : 2501
40-
Well-typed checkable : 1609
38+
All : 2763
39+
Checkable : 2502
40+
Well-typed checkable : 1610
4141
Checkable ratio : 91%
4242
Health ratio of checkable : 64%
4343
error count : 891

eqwalizer/test_projects/_cli/discarded_specs.cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ type_aliases:uses_trans_unbound_var/2
4949
type_aliases:uses_ty_w_unbound_var/2
5050
type_aliases:uses_ty_w_unbound_var2/0
5151
Discarded specs: 49
52-
Total specs: 2640
53-
Discarded ratio: 1.8561 %
52+
Total specs: 2641
53+
Discarded ratio: 1.8554 %

eqwalizer/test_projects/_cli/misc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,8 @@
25592559
"module": "gradual_misc",
25602560
"exported_funs": [
25612561
"use_invalid_opaque_1/1",
2562-
"use_invalid_opaque_2/1"
2562+
"use_invalid_opaque_2/1",
2563+
"f/1"
25632564
]
25642565
},
25652566
{

eqwalizer/test_projects/_cli/numbers.cli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
all specs:
2-
containing number: 13.32%
3-
containing integer: 10.51%
2+
containing number: 13.31%
3+
containing integer: 10.50%
44
containing pos_integer: 3.34%
55
containing non_neg_integer: 2.05%
66
containing neg_integer: 1.52%
@@ -21,8 +21,8 @@ generated specs:
2121
containing range: 0.00%
2222
containing int lit: 0.00%
2323
non-generated specs:
24-
containing number: 13.32%
25-
containing integer: 10.51%
24+
containing number: 13.31%
25+
containing integer: 10.50%
2626
containing pos_integer: 3.34%
2727
containing non_neg_integer: 2.05%
2828
containing neg_integer: 1.52%

eqwalizer/test_projects/check_gradual/src/gradual_misc.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ use_invalid_opaque_1(X) ->
2020
) -> opaque:contravariant(a).
2121
use_invalid_opaque_2(X) ->
2222
X.
23+
24+
-spec f(map()) -> ok.
25+
f(#{(#{} =/= a) := _}) ->
26+
ok.

eqwalizer/test_projects/check_gradual/src/gradual_misc.erl.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ use_invalid_opaque_1(X) -> | |
2222
) -> opaque:contravariant(a). | |
2323
use_invalid_opaque_2(X) -> | |
2424
X. | |
25+
| |
26+
-spec f(map()) -> ok. | |
27+
f(#{(#{} =/= a) := _}) -> | OK |
28+
ok. | |

0 commit comments

Comments
 (0)