Skip to content

Commit 5cd3edf

Browse files
VLanvinfacebook-github-bot
authored andcommitted
Error tolerance for functional args -- snapshot test
Summary: Snapshot test for repeated errors with functional arguments. Attempted to minimalise it as much as possible. Reviewed By: ilya-klyuchnikov Differential Revision: D43187018 fbshipit-source-id: 4082ea70af43741b67b9cd177c50120b4f2f274f
1 parent 50395e0 commit 5cd3edf

File tree

9 files changed

+128
-25
lines changed

9 files changed

+128
-25
lines changed

eqwalizer/test_projects/_cli/checkable_funs.cli

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
all funs:
2-
All : 2930
3-
Checkable : 2675
4-
Well-typed checkable : 1705
2+
All : 2933
3+
Checkable : 2678
4+
Well-typed checkable : 1707
55
Checkable ratio : 91%
66
Health ratio of checkable : 64%
7-
error count : 969
7+
error count : 970
88

99
--------------------------------------------
1010
generated funs:
@@ -26,19 +26,19 @@ generated non-test funs:
2626

2727
--------------------------------------------
2828
non-generated funs:
29-
All : 2930
30-
Checkable : 2675
31-
Well-typed checkable : 1705
29+
All : 2933
30+
Checkable : 2678
31+
Well-typed checkable : 1707
3232
Checkable ratio : 91%
3333
Health ratio of checkable : 64%
34-
error count : 969
34+
error count : 970
3535

3636
--------------------------------------------
3737
non-generated non-test funs (most important):
38-
All : 2928
39-
Checkable : 2673
40-
Well-typed checkable : 1704
38+
All : 2931
39+
Checkable : 2676
40+
Well-typed checkable : 1706
4141
Checkable ratio : 91%
4242
Health ratio of checkable : 64%
43-
error count : 968
43+
error count : 969
4444

eqwalizer/test_projects/_cli/discarded_specs.cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ type_aliases:uses_trans_unbound_var/2
4242
type_aliases:uses_ty_w_unbound_var/2
4343
type_aliases:uses_ty_w_unbound_var2/0
4444
Discarded specs: 42
45-
Total specs: 2803
46-
Discarded ratio: 1.4984 %
45+
Total specs: 2806
46+
Discarded ratio: 1.4968 %
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Average error message length: 22.345623 characters
1+
Average error message length: 22.340622 characters
22
Longest error message: 122 characters
33
Average error message length for the longest 10% of error msgs: 47.34884 characters

eqwalizer/test_projects/_cli/misc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3550,7 +3550,10 @@
35503550
"use_invalid/1",
35513551
"fixmes/1",
35523552
"fixmes_neg/1",
3553-
"redundant_fixme/0"
3553+
"redundant_fixme/0",
3554+
"make_pair/2",
3555+
"map_pair/2",
3556+
"apply_map/1"
35543557
]
35553558
}
35563559
]

eqwalizer/test_projects/_cli/otp_funs.cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ gb_sets 26
1717
proplists 51
1818
maps 164
1919
lists 168
20-
erlang 366
20+
erlang 367
2121
Per app stats:
2222
runtime_tools 12
2323
kernel 21
24-
erts 366
24+
erts 367
2525
stdlib 489

eqwalizer/test_projects/_cli/stats.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
]
1818
},
1919
"fault_tolerance": {
20-
"fun_cnt": 36,
20+
"fun_cnt": 39,
2121
"exported_cnt": 0,
22-
"well_typed_cnt": 4,
23-
"specced_cnt": 36,
24-
"well_typed_specced_cnt": 4,
25-
"well_typed_exported_cnt": 4,
26-
"well_typed_exported_specced_cnt": 4,
22+
"well_typed_cnt": 6,
23+
"specced_cnt": 39,
24+
"well_typed_specced_cnt": 6,
25+
"well_typed_exported_cnt": 6,
26+
"well_typed_exported_specced_cnt": 6,
2727
"fixme_count": 7,
2828
"is_generated": false,
2929
"eqwalizer_enabled": true,
30-
"error_count": 96,
30+
"error_count": 101,
3131
"is_test": false,
3232
"type_dependencies": [
3333
"misc"

eqwalizer/test_projects/fault_tolerance/src/fault_tolerance.erl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,14 @@ fixmes_neg(Atom) ->
351351
redundant_fixme() ->
352352
% eqwalizer:fixme
353353
ok.
354+
355+
% Error tolerance with fun args
356+
-spec make_pair(K, number()) -> {K, number()}.
357+
make_pair(K, V) -> {K, V}.
358+
359+
-spec map_pair([{K, V}], fun ((K, V) -> {K, A})) -> [{K, A}].
360+
map_pair(_, _) -> error(unimplemented).
361+
362+
-spec apply_map([{atom(), term()}]) -> [{atom(), number()}].
363+
apply_map(L) ->
364+
map_pair(L, fun make_pair/2).

eqwalizer/test_projects/fault_tolerance/src/fault_tolerance.erl.check

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,32 @@ redundant_fixme() -> | OK |
564564
% eqwalizer:fixme | | redundant fixme
565565

566566
ok. | |
567+
| |
568+
% Error tolerance with fun args | |
569+
-spec make_pair(K, number()) -> {K, number…… |
570+
make_pair(K, V) -> {K, V}. | OK |
571+
| |
572+
-spec map_pair([{K, V}], fun ((K, V) -> {K…… |
573+
map_pair(_, _) -> error(unimplemented). | OK |
574+
| |
575+
-spec apply_map([{atom(), term()}]) -> [{a…… |
576+
apply_map(L) -> | ERROR |
577+
map_pair(L, fun make_pair/2). | | Arg 2 of 'make_pair/2'.
578+
| | Expected: number()
579+
| | Got : term()
580+
| | ---
581+
| | Arg 2 of 'make_pair/2'.
582+
| | Expected: number()
583+
| | Got : term()
584+
| | ---
585+
| | Arg 2 of 'make_pair/2'.
586+
| | Expected: number()
587+
| | Got : term()
588+
| | ---
589+
| | Arg 2 of 'make_pair/2'.
590+
| | Expected: number()
591+
| | Got : term()
592+
| | ---
593+
| | Arg 2 of 'make_pair/2'.
594+
| | Expected: number()
595+
| | Got : term()

eqwalizer/test_projects/fault_tolerance/src/fault_tolerance.erl.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,66 @@
11511151
"code": "redundant_fixme",
11521152
"expressionOrNull": null,
11531153
"explanationOrNull": null
1154+
},
1155+
{
1156+
"range": {
1157+
"start": 5291,
1158+
"end": 5306
1159+
},
1160+
"lineAndCol": null,
1161+
"message": "Expected: number()\nGot : term()",
1162+
"uri": "https://fb.me/eqwalizer_errors#expected_subtype",
1163+
"code": "expected_subtype",
1164+
"expressionOrNull": "Arg 2 of 'make_pair/2'",
1165+
"explanationOrNull": null
1166+
},
1167+
{
1168+
"range": {
1169+
"start": 5291,
1170+
"end": 5306
1171+
},
1172+
"lineAndCol": null,
1173+
"message": "Expected: number()\nGot : term()",
1174+
"uri": "https://fb.me/eqwalizer_errors#expected_subtype",
1175+
"code": "expected_subtype",
1176+
"expressionOrNull": "Arg 2 of 'make_pair/2'",
1177+
"explanationOrNull": null
1178+
},
1179+
{
1180+
"range": {
1181+
"start": 5291,
1182+
"end": 5306
1183+
},
1184+
"lineAndCol": null,
1185+
"message": "Expected: number()\nGot : term()",
1186+
"uri": "https://fb.me/eqwalizer_errors#expected_subtype",
1187+
"code": "expected_subtype",
1188+
"expressionOrNull": "Arg 2 of 'make_pair/2'",
1189+
"explanationOrNull": null
1190+
},
1191+
{
1192+
"range": {
1193+
"start": 5291,
1194+
"end": 5306
1195+
},
1196+
"lineAndCol": null,
1197+
"message": "Expected: number()\nGot : term()",
1198+
"uri": "https://fb.me/eqwalizer_errors#expected_subtype",
1199+
"code": "expected_subtype",
1200+
"expressionOrNull": "Arg 2 of 'make_pair/2'",
1201+
"explanationOrNull": null
1202+
},
1203+
{
1204+
"range": {
1205+
"start": 5291,
1206+
"end": 5306
1207+
},
1208+
"lineAndCol": null,
1209+
"message": "Expected: number()\nGot : term()",
1210+
"uri": "https://fb.me/eqwalizer_errors#expected_subtype",
1211+
"code": "expected_subtype",
1212+
"expressionOrNull": "Arg 2 of 'make_pair/2'",
1213+
"explanationOrNull": null
11541214
}
11551215
]
11561216
}

0 commit comments

Comments
 (0)