Skip to content

Commit 23cfff8

Browse files
committed
Move should-fail tests which now fail where they belong
1 parent e15dcbe commit 23cfff8

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

test/known_problems/should_fail/poly_should_fail.erl

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
id_id_atom_is_int/1,
99
id_fun_id_atom_is_int/1,
1010
use_flatten/1,
11-
use_maps_get/3,
1211
use_generic_hd/1,
1312
use_generic_hd_var/1,
1413
inference1/1,
15-
inference2/1,
16-
invariant_tyvar/2
14+
inference2/1
1715
]).
1816

1917
-spec id(A) -> A.
@@ -56,11 +54,6 @@ pass_id_to_takes_int_to_bool_fun() ->
5654
use_flatten(ListOfListsOfAtoms) ->
5755
lists:flatten(ListOfListsOfAtoms).
5856

59-
%% Type variables in maps usually result in any().
60-
-spec use_maps_get(atom(), #{atom() => binary()}, not_found) -> float() | not_found.
61-
use_maps_get(Key, Map, NotFound) ->
62-
maps:get(Key, Map, NotFound).
63-
6457
%% We do not support polymorphic intersection functions yet.
6558
%% When calling intersection functions, type variables are replaced with any().
6659

@@ -88,20 +81,3 @@ inference1(L) ->
8881
-spec inference2([integer()]) -> [atom()].
8982
inference2(L) ->
9083
lists:map(fun (I) -> I * 2 end, L).
91-
92-
%% The type variable `A` in `id_fun_arg/2` is invariant in its result type.
93-
%% Thus, if there are multiple possible substitutions, none of them is minimal.
94-
%% In this case we choose `A = the_lower_bound_of_A | any()' which is a bit
95-
%% lenient in some cases, as shown in invariant_tyvar/2. Hopefully, invariant
96-
%% type variables are very rare.
97-
98-
-spec id_fun_arg(fun ((A) -> B), A) -> {fun ((A) -> B), A}.
99-
id_fun_arg(Fun, Arg) -> {Fun, Arg}.
100-
101-
-spec positive(number()) -> boolean().
102-
positive(N) -> N > 0.
103-
104-
-spec invariant_tyvar(integer(), boolean()) -> any().
105-
invariant_tyvar(Int, Bool) ->
106-
{Fun, _Arg} = id_fun_arg(fun positive/1, Int),
107-
Fun(Bool).

test/should_fail/poly_fail.erl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use_app_var/1,
1414
use_id/1,
1515
use_id_var/1,
16+
use_maps_get/3,
1617
filter_positive_ints/1,
1718
filter_positive_concrete_numbers/1,
1819
append_floats_to_ints/2,
@@ -34,7 +35,8 @@
3435
use_enum_map1/1,
3536
use_enum_map1_var/1,
3637
use_enum_map2/1,
37-
use_enum_map3/1
38+
use_enum_map3/1,
39+
invariant_tyvar/2
3840
]).
3941

4042
-gradualizer([solve_constraints]).
@@ -110,6 +112,11 @@ use_id_var(Atom) ->
110112
X = id(Atom),
111113
X.
112114

115+
%% Type variables in maps usually result in any().
116+
-spec use_maps_get(atom(), #{atom() => binary()}, not_found) -> float() | not_found.
117+
use_maps_get(Key, Map, NotFound) ->
118+
maps:get(Key, Map, NotFound).
119+
113120
-spec positive(number()) -> boolean().
114121
positive(N) -> N > 0.
115122

@@ -239,3 +246,17 @@ use_enum_map2(Atoms) ->
239246
-spec use_enum_map3(#{'__struct__' := some_struct}) -> [float()].
240247
use_enum_map3(SomeStruct) ->
241248
enum_map(SomeStruct, fun positive/1).
249+
250+
%% The type variable `A` in `id_fun_arg/2` is invariant in its result type.
251+
%% Thus, if there are multiple possible substitutions, none of them is minimal.
252+
%% In this case we choose `A = the_lower_bound_of_A | any()' which is a bit
253+
%% lenient in some cases, as shown in invariant_tyvar/2. Hopefully, invariant
254+
%% type variables are very rare.
255+
256+
-spec id_fun_arg(fun ((A) -> B), A) -> {fun ((A) -> B), A}.
257+
id_fun_arg(Fun, Arg) -> {Fun, Arg}.
258+
259+
-spec invariant_tyvar(integer(), boolean()) -> any().
260+
invariant_tyvar(Int, Bool) ->
261+
{Fun, _Arg} = id_fun_arg(fun positive/1, Int),
262+
Fun(Bool).

0 commit comments

Comments
 (0)