aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-01-16 07:02:54 +0100
committerBjörn Gustavsson <[email protected]>2015-01-26 12:58:11 +0100
commit62c1dd9d9994367da43212f1b33c9e2dacb27e4b (patch)
tree49cf924637c44c6e5fcd6f493017fc7c736289b0 /lib/compiler/src
parent3f7ab0ea59deedd63da8dbaa9dbdbf5666294d6c (diff)
downloadotp-62c1dd9d9994367da43212f1b33c9e2dacb27e4b.tar.gz
otp-62c1dd9d9994367da43212f1b33c9e2dacb27e4b.tar.bz2
otp-62c1dd9d9994367da43212f1b33c9e2dacb27e4b.zip
core_lib: Teach is_var_used/2 to handle keys in map patterns
is_var_used/2 did not notice that variable keys in map patterns were used, which could cause sys_core_fold to do unsafe optimizations.
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/core_lib.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/compiler/src/core_lib.erl b/lib/compiler/src/core_lib.erl
index 0d95971f91..730e3a5317 100644
--- a/lib/compiler/src/core_lib.erl
+++ b/lib/compiler/src/core_lib.erl
@@ -236,10 +236,15 @@ vu_pat_seg_list(V, Ss, St) ->
end
end, St, Ss).
-vu_map_pairs(V, [#c_map_pair{val=Pat}|T], St0) ->
- case vu_pattern(V, Pat, St0) of
- {true,_}=St -> St;
- St -> vu_map_pairs(V, T, St)
+vu_map_pairs(V, [#c_map_pair{key=Key,val=Pat}|T], St0) ->
+ case vu_expr(V, Key) of
+ true ->
+ {true,false};
+ false ->
+ case vu_pattern(V, Pat, St0) of
+ {true,_}=St -> St;
+ St -> vu_map_pairs(V, T, St)
+ end
end;
vu_map_pairs(_, [], St) -> St.