diff options
Diffstat (limited to 'lib/dialyzer')
-rw-r--r-- | lib/dialyzer/src/dialyzer_utils.erl | 31 | ||||
-rw-r--r-- | lib/dialyzer/test/map_SUITE_data/results/map_galore | 8 | ||||
-rw-r--r-- | lib/dialyzer/test/map_SUITE_data/results/maps_merge | 8 | ||||
-rw-r--r-- | lib/dialyzer/test/map_SUITE_data/results/typeflow2 | 18 | ||||
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/results/maps1 | 2 | ||||
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/results/maps_difftype | 2 |
6 files changed, 50 insertions, 19 deletions
diff --git a/lib/dialyzer/src/dialyzer_utils.erl b/lib/dialyzer/src/dialyzer_utils.erl index b3505f5197..721c2c000a 100644 --- a/lib/dialyzer/src/dialyzer_utils.erl +++ b/lib/dialyzer/src/dialyzer_utils.erl @@ -753,6 +753,13 @@ pp_hook(Node, Ctxt, Cont) -> pp_binary(Node, Ctxt, Cont); bitstr -> pp_segment(Node, Ctxt, Cont); + map -> + pp_map(Node, Ctxt, Cont); + literal -> + case is_map(cerl:concrete(Node)) of + true -> pp_map(Node, Ctxt, Cont); + false -> Cont(Node, Ctxt) + end; _ -> Cont(Node, Ctxt) end. @@ -833,6 +840,30 @@ pp_atom(Atom) -> String = atom_to_list(cerl:atom_val(Atom)), prettypr:text(String). +pp_map(Node, Ctxt, Cont) -> + Arg = cerl:map_arg(Node), + Before = case cerl:is_c_map_empty(Arg) of + true -> prettypr:floating(prettypr:text("#{")); + false -> + prettypr:beside(Cont(Arg,Ctxt), + prettypr:floating(prettypr:text("#{"))) + end, + prettypr:beside( + Before, prettypr:beside( + prettypr:par(seq(cerl:map_es(Node), + prettypr:floating(prettypr:text(",")), + Ctxt, Cont)), + prettypr:floating(prettypr:text("}")))). + +seq([H | T], Separator, Ctxt, Fun) -> + case T of + [] -> [Fun(H, Ctxt)]; + _ -> [prettypr:beside(Fun(H, Ctxt), Separator) + | seq(T, Separator, Ctxt, Fun)] + end; +seq([], _, _, _) -> + [prettypr:empty()]. + %%------------------------------------------------------------------------------ -spec refold_pattern(cerl:cerl()) -> cerl:cerl(). diff --git a/lib/dialyzer/test/map_SUITE_data/results/map_galore b/lib/dialyzer/test/map_SUITE_data/results/map_galore index 721b417bb3..6ea88f01f8 100644 --- a/lib/dialyzer/test/map_SUITE_data/results/map_galore +++ b/lib/dialyzer/test/map_SUITE_data/results/map_galore @@ -16,10 +16,10 @@ map_galore.erl:1498: The test #{'a':=1, 'b':=1} =:= #{'a':=1, 'b':=3} can never map_galore.erl:1762: The call maps:get({1, 1},#{{1,float()}=>[101 | 108 | 112 | 116 | 117,...]}) will never return since the success typing arguments are (any(),map()) map_galore.erl:1763: The call maps:get('a',#{}) will never return since the success typing arguments are (any(),map()) map_galore.erl:1765: The call maps:get('a',#{'b':=1, 'c':=2}) will never return since the success typing arguments are (any(),map()) -map_galore.erl:186: The pattern ~{'x':=2}~ can never match the type #{'x':=3} -map_galore.erl:187: The pattern ~{'x':=3}~ can never match the type {'a','b','c'} -map_galore.erl:188: The pattern ~{'x':=3}~ can never match the type #{'y':=3} -map_galore.erl:189: The pattern ~{'x':=3}~ can never match the type #{'x':=[101 | 104 | 114 | 116,...]} +map_galore.erl:186: The pattern #{'x':=2} can never match the type #{'x':=3} +map_galore.erl:187: The pattern #{'x':=3} can never match the type {'a','b','c'} +map_galore.erl:188: The pattern #{'x':=3} can never match the type #{'y':=3} +map_galore.erl:189: The pattern #{'x':=3} can never match the type #{'x':=[101 | 104 | 114 | 116,...]} map_galore.erl:2304: Cons will produce an improper list since its 2nd argument is {'b','a'} map_galore.erl:2304: The call maps:from_list(nonempty_improper_list({'a','b'},{'b','a'})) will never return since it differs in the 1st argument from the success typing arguments: ([{_,_}]) map_galore.erl:2305: The call maps:from_list('a') will never return since it differs in the 1st argument from the success typing arguments: ([{_,_}]) diff --git a/lib/dialyzer/test/map_SUITE_data/results/maps_merge b/lib/dialyzer/test/map_SUITE_data/results/maps_merge index 696f6e19d2..0c347b4cdb 100644 --- a/lib/dialyzer/test/map_SUITE_data/results/maps_merge +++ b/lib/dialyzer/test/map_SUITE_data/results/maps_merge @@ -1,11 +1,11 @@ maps_merge.erl:10: The pattern #{_:=_} can never match the type #{'a':=1, 3:='ok', 'q'=>none(), 7=>none(), atom() | integer()=>_} maps_merge.erl:12: Function t3/0 has no local return -maps_merge.erl:14: The pattern ~{7:='q'}~ can never match the type #{'a':=1, 3:='ok', 'q'=>none(), 7=>none(), atom() | integer()=>_} +maps_merge.erl:14: The pattern #{7:='q'} can never match the type #{'a':=1, 3:='ok', 'q'=>none(), 7=>none(), atom() | integer()=>_} maps_merge.erl:16: Function t4/0 has no local return -maps_merge.erl:18: The pattern ~{7:='q'}~ can never match the type #{'a':=1, 3:='ok', 'q'=>none(), 7=>none(), atom() | integer()=>_} +maps_merge.erl:18: The pattern #{7:='q'} can never match the type #{'a':=1, 3:='ok', 'q'=>none(), 7=>none(), atom() | integer()=>_} maps_merge.erl:20: Function t5/0 has no local return -maps_merge.erl:21: The pattern ~{'a':=2}~ can never match the type #{'a':=1, 'q'=>none(), 11=>_, atom()=>_} +maps_merge.erl:21: The pattern #{'a':=2} can never match the type #{'a':=1, 'q'=>none(), 11=>_, atom()=>_} maps_merge.erl:5: Function t1/0 has no local return -maps_merge.erl:6: The pattern ~{'a':=1}~ can never match the type #{} +maps_merge.erl:6: The pattern #{'a':=1} can never match the type #{} maps_merge.erl:8: Function t2/0 has no local return diff --git a/lib/dialyzer/test/map_SUITE_data/results/typeflow2 b/lib/dialyzer/test/map_SUITE_data/results/typeflow2 index 3bce165275..3adf638978 100644 --- a/lib/dialyzer/test/map_SUITE_data/results/typeflow2 +++ b/lib/dialyzer/test/map_SUITE_data/results/typeflow2 @@ -1,13 +1,13 @@ -typeflow2.erl:10: The pattern ~{'a':=X}~ can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} -typeflow2.erl:11: The pattern ~{'a':=X}~ can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} +typeflow2.erl:10: The pattern #{'a':=X} can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} +typeflow2.erl:11: The pattern #{'a':=X} can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} typeflow2.erl:26: Function t2/1 has no local return typeflow2.erl:29: The call lists:sort(integer()) will never return since it differs in the 1st argument from the success typing arguments: ([any()]) -typeflow2.erl:42: The pattern ~{'a':=X}~ can never match since previous clauses completely covered the type #{'a':=integer()} +typeflow2.erl:42: The pattern #{'a':=X} can never match since previous clauses completely covered the type #{'a':=integer()} typeflow2.erl:43: The variable _ can never match since previous clauses completely covered the type #{'a':=integer()} -typeflow2.erl:48: The pattern ~{}~ can never match since previous clauses completely covered the type #{'a':=atom() | maybe_improper_list() | integer()} -typeflow2.erl:58: The pattern ~{'a':=X}~ can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} -typeflow2.erl:59: The pattern ~{'a':=X}~ can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} -typeflow2.erl:60: The pattern ~{'a':=X}~ can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} -typeflow2.erl:82: The pattern ~{'a':=X}~ can never match the type #{} -typeflow2.erl:83: The pattern ~{'a':=X}~ can never match the type #{} +typeflow2.erl:48: The pattern #{} can never match since previous clauses completely covered the type #{'a':=atom() | maybe_improper_list() | integer()} +typeflow2.erl:58: The pattern #{'a':=X} can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} +typeflow2.erl:59: The pattern #{'a':=X} can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} +typeflow2.erl:60: The pattern #{'a':=X} can never match the type #{'a'=>none(), _=>maybe_improper_list() | integer()} +typeflow2.erl:82: The pattern #{'a':=X} can never match the type #{} +typeflow2.erl:83: The pattern #{'a':=X} can never match the type #{} diff --git a/lib/dialyzer/test/small_SUITE_data/results/maps1 b/lib/dialyzer/test/small_SUITE_data/results/maps1 index ec8748b7b8..a178e96b20 100644 --- a/lib/dialyzer/test/small_SUITE_data/results/maps1 +++ b/lib/dialyzer/test/small_SUITE_data/results/maps1 @@ -1,4 +1,4 @@ maps1.erl:43: Function t3/0 has no local return -maps1.erl:44: The call maps1:foo(~{'greger'=>3, ~{'arne'=>'anka'}~=>45}~,1) will never return since it differs in the 1st and 2nd argument from the success typing arguments: (#{'beta':=_, ...},'b') +maps1.erl:44: The call maps1:foo(#{'greger'=>3, #{'arne'=>'anka'}=>45},1) will never return since it differs in the 1st and 2nd argument from the success typing arguments: (#{'beta':=_, ...},'b') maps1.erl:52: The variable Mod can never match since previous clauses completely covered the type #{} diff --git a/lib/dialyzer/test/small_SUITE_data/results/maps_difftype b/lib/dialyzer/test/small_SUITE_data/results/maps_difftype index 8980321135..3018b888db 100644 --- a/lib/dialyzer/test/small_SUITE_data/results/maps_difftype +++ b/lib/dialyzer/test/small_SUITE_data/results/maps_difftype @@ -1,3 +1,3 @@ maps_difftype.erl:10: Function empty_mismatch/1 has no local return -maps_difftype.erl:11: The pattern ~{}~ can never match the type tuple() +maps_difftype.erl:11: The pattern #{} can never match the type tuple() |