Skip to content

Commit

Permalink
Extract test/should_pass/poly_map_pattern.erl
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Dec 3, 2022
1 parent bf92049 commit 84490d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
13 changes: 0 additions & 13 deletions test/should_pass/map_pattern.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
map_union/1,
any_map/1,
map_term/1,
map_type_var/1,
map_pattern_no_spec/1]).

-gradualizer([solve_constraints]).

-type t() :: #{apa := integer(), bepa := boolean()}.

-spec f(t()) -> boolean().
Expand All @@ -31,14 +28,4 @@ any_map(#{apa := _}) -> ok.
map_term(#{}) ->
ok.

-spec map_type_var(nonempty_list(#{atom() => integer()})) -> integer().
map_type_var(L) ->
V = lists:nth(2, L),
%% at this point V :: T
case V of
%% pattern matching a map against a type var
#{k := Int} ->
Int
end.

map_pattern_no_spec(#{} = _Map) -> ok.
15 changes: 15 additions & 0 deletions test/should_pass/poly_map_pattern.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-module(poly_map_pattern).

-gradualizer([solve_constraints]).

-export([map_type_var/1]).

-spec map_type_var(nonempty_list(#{atom() => integer()})) -> integer().
map_type_var(L) ->
V = lists:nth(2, L),
%% at this point V :: T
case V of
%% pattern matching a map against a type var
#{k := Int} ->
Int
end.

0 comments on commit 84490d4

Please sign in to comment.