Skip to content

Commit b3fa428

Browse files
clean up: overloadedSpecDomainCheck is always on
Summary: - as title - moving overloaded_specs_union.erl from options to check test project - regenerating snapshot outputs, which triggers a few more type errors Reviewed By: michalmuskala, TD5 Differential Revision: D65595959 fbshipit-source-id: 2570d414973cd52be6c79d58a2f3186dd71c0dae
1 parent 8e57923 commit b3fa428

File tree

9 files changed

+89
-17
lines changed

9 files changed

+89
-17
lines changed

crates/elp/src/bin/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,6 @@ mod tests {
17441744
fault_tolerance: Some(true),
17451745
clause_coverage: Some(true),
17461746
report_bad_maps: Some(true),
1747-
overloaded_spec_domain_check: Some(true),
17481747
report_dynamic_lambdas: Some(true),
17491748
..EqwalizerConfig::default_test()
17501749
},

crates/elp/src/resources/test/eqwalizer_tests/check/custom.pretty

+18-1
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,23 @@ Context expected type: #{c := atom()}
17711771

17721772
See https://fb.me/eqwalizer_errors#incompatible_types
17731773

1774+
error: incompatible_types
1775+
┌─ check/src/custom.erl:1916:23
1776+
1777+
1916 │ custom_overloaded(X).
1778+
│ ^
1779+
│ │
1780+
│ X.
1781+
Expression has type: term()
1782+
Context expected type: atom() | binary()
1783+
1784+
See https://fb.me/eqwalizer_errors#incompatible_types
1785+
1786+
1787+
term() is not compatible with atom() | binary()
1788+
because
1789+
term() is not compatible with atom()
1790+
17741791
error: incompatible_types
17751792
┌─ check/src/custom.erl:1939:5
17761793
@@ -2278,4 +2295,4 @@ See https://fb.me/eqwalizer_errors#incompatible_types
22782295
at tuple index 1:
22792296
{'ok', atom()} is not compatible with {'error', term()}
22802297

2281-
159 ERRORS
2298+
160 ERRORS

crates/elp/src/resources/test/eqwalizer_tests/check/overloaded.pretty

+52-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@ Context expected type: atom()
88

99
See https://fb.me/eqwalizer_errors#incompatible_types
1010

11+
error: incompatible_types
12+
┌─ check/src/overloaded.erl:117:15
13+
14+
117 │ Res = bar(F),
15+
│ ^
16+
│ │
17+
│ F.
18+
Expression has type: fun(('a') -> 'z')
19+
Context expected type: fun(('a') -> 'b') | fun(('a') -> 'c')
20+
21+
See https://fb.me/eqwalizer_errors#incompatible_types
22+
23+
24+
fun(('a') -> 'z') is not compatible with fun(('a') -> 'b') | fun(('a') -> 'c')
25+
because
26+
fun(('a') -> 'z') is not compatible with fun(('a') -> 'b')
27+
because
28+
'z' is not compatible with 'b'
29+
30+
error: incompatible_types
31+
┌─ check/src/overloaded.erl:126:15
32+
33+
126 │ Res = bar({fun(a) -> a end}),
34+
│ ^^^^^^^^^^^^^^^^^
35+
│ │
36+
│ {fun}.
37+
Expression has type: {fun((dynamic()) -> dynamic())}
38+
Context expected type: fun(('a') -> 'b') | fun(('a') -> 'c')
39+
40+
See https://fb.me/eqwalizer_errors#incompatible_types
41+
42+
43+
expected union does not contain any tuple type of size 1
44+
1145
error: incompatible_types
1246
┌─ check/src/overloaded.erl:141:5
1347
@@ -82,6 +116,23 @@ error: reference_to_invalid_type
82116

83117
See https://fb.me/eqwalizer_errors#reference_to_invalid_type
84118

119+
error: incompatible_types
120+
┌─ check/src/overloaded.erl:269:14
121+
122+
269 │ _ = swap(""),
123+
│ ^^
124+
│ │
125+
│ string_lit.
126+
Expression has type: []
127+
Context expected type: atom() | binary()
128+
129+
See https://fb.me/eqwalizer_errors#incompatible_types
130+
131+
132+
[] is not compatible with atom() | binary()
133+
because
134+
[] is not compatible with atom()
135+
85136
error: incompatible_types
86137
┌─ check/src/overloaded.erl:290:5
87138
@@ -102,4 +153,4 @@ Context expected type: 'a'
102153

103154
See https://fb.me/eqwalizer_errors#incompatible_types
104155

105-
10 ERRORS
156+
13 ERRORS

crates/elp/src/resources/test/eqwalizer_tests/options/overloaded_specs_union.pretty crates/elp/src/resources/test/eqwalizer_tests/check/overloaded_specs_union.pretty

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: incompatible_types
2-
┌─ options/src/overloaded_specs_union.erl:16:29
2+
┌─ check/src/overloaded_specs_union.erl:16:29
33
44
16 │ use_over_neg_1(Arg) -> over(Arg).
55
│ ^^^
@@ -16,7 +16,7 @@ See https://fb.me/eqwalizer_errors#incompatible_types
1616
pid() is not compatible with atom()
1717

1818
error: incompatible_types
19-
┌─ options/src/overloaded_specs_union.erl:19:29
19+
┌─ check/src/overloaded_specs_union.erl:19:29
2020
2121
19 │ use_over_neg_2(Arg) -> over(Arg).
2222
│ ^^^

crates/elp/src/resources/test/eqwalizer_tests/check_gradual/gradual_overloaded.pretty

+11-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ Context expected type: number()
4949

5050
See https://fb.me/eqwalizer_errors#incompatible_types
5151

52-
5 ERRORS
52+
error: incompatible_types
53+
┌─ check_gradual/src/gradual_overloaded.erl:128:19
54+
55+
128 │ fun(I) -> I + 1 end,
56+
│ ^ I.
57+
Expression has type: #r{}
58+
Context expected type: number()
59+
60+
See https://fb.me/eqwalizer_errors#incompatible_types
61+
62+
6 ERRORS

crates/eqwalizer/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pub struct EqwalizerConfig {
6969
pub occurrence_typing: Option<bool>,
7070
pub clause_coverage: Option<bool>,
7171
pub report_bad_maps: Option<bool>,
72-
pub overloaded_spec_domain_check: Option<bool>,
7372
pub overloaded_spec_dynamic_result: Option<bool>,
7473
pub report_dynamic_lambdas: Option<bool>,
7574
}
@@ -83,8 +82,6 @@ impl EqwalizerConfig {
8382
.map(|cfg| cmd.env("EQWALIZER_CLAUSE_COVERAGE", cfg.to_string()));
8483
self.report_bad_maps
8584
.map(|cfg| cmd.env("EQWALIZER_REPORT_BAD_MAPS", cfg.to_string()));
86-
self.overloaded_spec_domain_check
87-
.map(|cfg| cmd.env("EQWALIZER_OVERLOADED_SPEC_DOMAIN_CHECK", cfg.to_string()));
8885
self.overloaded_spec_dynamic_result
8986
.map(|cfg| cmd.env("EQWALIZER_OVERLOADED_SPEC_DYNAMIC_RESULT", cfg.to_string()));
9087
self.report_dynamic_lambdas
@@ -97,7 +94,6 @@ impl EqwalizerConfig {
9794
occurrence_typing: Some(true),
9895
clause_coverage: Some(false),
9996
report_bad_maps: Some(false),
100-
overloaded_spec_domain_check: Some(false),
10197
overloaded_spec_dynamic_result: Some(false),
10298
report_dynamic_lambdas: Some(false),
10399
}

test_projects/eqwalizer_tests/check/src/overloaded.erl

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ test_bar3(F) ->
112112
Res = bar(F),
113113
Res.
114114

115-
-spec test_bar4(fun((a) -> z)) -> z.
116-
test_bar4(F) ->
115+
-spec test_bar4_neg(fun((a) -> z)) -> z.
116+
test_bar4_neg(F) ->
117117
Res = bar(F),
118118
Res.
119119

120120
-spec inner_bar({fun((a) -> b)}) -> b;
121121
({fun((a) -> c)}) -> c.
122122
inner_bar(_) -> throw(err).
123123

124-
-spec test_inner_bar() -> b.
125-
test_inner_bar() ->
124+
-spec test_inner_bar_neg() -> b.
125+
test_inner_bar_neg() ->
126126
Res = bar({fun(a) -> a end}),
127127
Res.
128128

test_projects/eqwalizer_tests/check_gradual/src/gradual_overloaded.erl

+2-3
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ rec_each3_neg(Rec) ->
121121
Rec
122122
).
123123

124-
% optimistically assuming dynamic()
125-
-spec rec_each4
124+
-spec rec_each4_neg
126125
(#r{} | [#r{}]) -> atom().
127-
rec_each4(Rec) ->
126+
rec_each4_neg(Rec) ->
128127
rec_each(
129128
fun(I) -> I + 1 end,
130129
Rec

0 commit comments

Comments
 (0)