aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-02-02 15:31:36 +0100
committerBjörn Gustavsson <[email protected]>2015-02-03 07:34:17 +0100
commitd9ed708bb5d22cf61029eac0a23b9d3dc94a5146 (patch)
tree7fd554546afbef6a0bd9be4aefc5024c7bc49a94 /lib/compiler/test
parentedf6a220668d7461044918c10190b41ea7a4891d (diff)
downloadotp-d9ed708bb5d22cf61029eac0a23b9d3dc94a5146.tar.gz
otp-d9ed708bb5d22cf61029eac0a23b9d3dc94a5146.tar.bz2
otp-d9ed708bb5d22cf61029eac0a23b9d3dc94a5146.zip
Do not convert map patterns to map expressions
In code such as: case {a,Map} of {a,#{}}=T -> T end we must NOT rewrite a map pattern to a map expression like this: case Map of #{} -> {a,#{}} end because the pattern '#{}' will match any map, but the expression '#{}' will construct an empty map.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/match_SUITE.erl7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/compiler/test/match_SUITE.erl b/lib/compiler/test/match_SUITE.erl
index e5aaf49d6f..1e778dca24 100644
--- a/lib/compiler/test/match_SUITE.erl
+++ b/lib/compiler/test/match_SUITE.erl
@@ -406,12 +406,19 @@ underscore(Config) when is_list(Config) ->
match_map(Config) when is_list(Config) ->
Map = #{key=>{x,y},ignore=>anything},
#s{map=Map,t={x,y}} = do_match_map(#s{map=Map}),
+ {a,#{k:={a,b,c}}} = do_match_map_2(#{k=>{a,b,c}}),
ok.
do_match_map(#s{map=#{key:=Val}}=S) ->
%% Would crash with a 'badarg' exception.
S#s{t=Val}.
+do_match_map_2(Map) ->
+ case {a,Map} of
+ {a,#{k:=_}}=Tuple ->
+ Tuple
+ end.
+
coverage(Config) when is_list(Config) ->
%% Cover beam_dead.
ok = coverage_1(x, a),