Skip to content

Commit

Permalink
better keys in maps:fold for shapes: test
Browse files Browse the repository at this point in the history
Reviewed By: VLanvin

Differential Revision: D53231279

fbshipit-source-id: 03c8ad4c41cd2d417ed0cf705203d5c7e3a0f0d9
  • Loading branch information
ilya-klyuchnikov authored and facebook-github-bot committed Jan 31, 2024
1 parent 5da3a99 commit 5fa669b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eqwalizer/test_projects/_cli/otp_funs.cli
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ ets 16
filename 21
gb_sets 26
proplists 51
maps 149
maps 150
lists 169
erlang 396
Per app stats:
kernel 21
erts 396
stdlib 471
stdlib 472
11 changes: 11 additions & 0 deletions eqwalizer/test_projects/check/src/custom.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2284,3 +2284,14 @@ re_replace_5_neg(Subj) ->
re_replace_6_neg(Subj) ->
Res = re:replace(Subj, "+", "-", [{return, something}]),
Res.

-spec maps_fold_keys(#{a => atom(), b => atom()}) -> ok.
maps_fold_keys(M) ->
maps:fold(
fun(K, _V, Acc) -> process_key(K), Acc end,
ok,
M
).

-spec process_key(a | b) -> ok.
process_key(_K) -> ok.
17 changes: 17 additions & 0 deletions eqwalizer/test_projects/check/src/custom.erl.check
Original file line number Diff line number Diff line change
Expand Up @@ -3081,3 +3081,20 @@ re_replace_6_neg(Subj) -> | ERROR |
| | because
| | 'something' is not compatible with 'iodata' | 'list' | 'binary'
Res. | |
| |
-spec maps_fold_keys(#{a => atom(), b => a…… |
maps_fold_keys(M) -> | ERROR |
maps:fold( | |
fun(K, _V, Acc) -> process_key(K),…… | K.
| | Expression has type: atom()
| | Context expected type: 'a' | 'b'
| |
| | atom() is not compatible with 'a' | 'b'
| | because
| | atom() is not compatible with 'a'
ok, | |
M | |
). | |
| |
-spec process_key(a | b) -> ok. | |
process_key(_K) -> ok. | OK |

0 comments on commit 5fa669b

Please sign in to comment.