From 3d05725ceb26611ac8c19cc01df715089dc322d5 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Fri, 1 Sep 2017 11:44:36 +0200 Subject: dialyzer: Modify handling of singleton map key types The test case loop.erl shows that there is a problem with certain singleton key types. Here the internal representation toggles between #{a | b => ...} and #{a => ..., b => ...} The choice is to turn #{a | b => ...} into #{a => ..., b => ...} early (t_from_form()). The aim is to keep as much info as possible (in pairs). However, including complex singleton keys (tuples, maps) in this scheme is potentially too costly, and a bit complicated. So one more choice is made: let atoms and number (and nothing else) be singleton types, and let complex keys go into the default key. --- lib/hipe/test/opt_verify_SUITE.erl | 2 +- .../opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'lib/hipe/test') diff --git a/lib/hipe/test/opt_verify_SUITE.erl b/lib/hipe/test/opt_verify_SUITE.erl index 86083fa02b..a323c10503 100644 --- a/lib/hipe/test/opt_verify_SUITE.erl +++ b/lib/hipe/test/opt_verify_SUITE.erl @@ -44,7 +44,7 @@ call_elim(Config) -> Icode5 = call_elim_test_file(Config, F3, icode_call_elim), 0 = substring_count(binary:bin_to_list(Icode5), "is_key"), Icode6 = call_elim_test_file(Config, F3, no_icode_call_elim), - 3 = substring_count(binary:bin_to_list(Icode6), "is_key"), + 2 = substring_count(binary:bin_to_list(Icode6), "is_key"), ok. call_elim_test_file(Config, FileName, Option) -> diff --git a/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl b/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl index c8ddfa1e75..12875f41af 100644 --- a/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl +++ b/lib/hipe/test/opt_verify_SUITE_data/call_elim_test_branches_opt_poss.erl @@ -6,17 +6,11 @@ test(A) -> if A > 0 -> true = has_a_field(#{a=>true}), true = has_a_field(#{b=>1, a=>"2"}), - true = has_a_field(#{a=>5, c=>4}), - true = has_tuple_field(#{{ab, 1}=><<"qq">>, 1 =>0}), - true = has_tuple_field(#{up =>down, {ab, 1}=>[]}), - true = has_tuple_field(#{{ab, 1}=>42}); + true = has_a_field(#{a=>5, c=>4}); A =< 0 -> true = has_a_field(#{a=>q, 'A' =>nej}), true = has_a_field(#{a=>"hej", false=>true}), - true = has_a_field(#{a=>3}), - true = has_tuple_field(#{{ab, 1}=>q, 'A' =>nej}), - true = has_tuple_field(#{{ab, 1}=>"hej", false=>true}), - true = has_tuple_field(#{{ab, 1}=>3}) + true = has_a_field(#{a=>3}) end, true = has_nil_field(#{[] =>3, b =>"seven"}), true = has_nil_field(#{"seventeen"=>17, []=>nil}), -- cgit v1.2.3