aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test/compile_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-04-12 15:05:28 +0200
committerBjörn Gustavsson <[email protected]>2018-04-18 15:26:11 +0200
commit6626b2a4ac67631bef3144bf9eca41b5f49c3176 (patch)
tree6c7c2fc8135dc2975fc6b21b8eac245a7d9dbb74 /lib/compiler/test/compile_SUITE.erl
parent46a89739ebe59bb2d2b44639c9ea9869757d4b58 (diff)
downloadotp-6626b2a4ac67631bef3144bf9eca41b5f49c3176.tar.gz
otp-6626b2a4ac67631bef3144bf9eca41b5f49c3176.tar.bz2
otp-6626b2a4ac67631bef3144bf9eca41b5f49c3176.zip
core_lint: Handle repeated variables in map patterns correctly
Keys in map patterns are input variables, not pattern variables.
Diffstat (limited to 'lib/compiler/test/compile_SUITE.erl')
-rw-r--r--lib/compiler/test/compile_SUITE.erl24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl
index eee5bc733f..a1de8961bd 100644
--- a/lib/compiler/test/compile_SUITE.erl
+++ b/lib/compiler/test/compile_SUITE.erl
@@ -1111,10 +1111,30 @@ remove_compiler_gen(M) ->
remove_compiler_gen_1(Pair) ->
Op0 = cerl:map_pair_op(Pair),
Op = cerl:set_ann(Op0, []),
- K = cerl:map_pair_key(Pair),
- V = cerl:map_pair_val(Pair),
+ K = map_var(cerl:map_pair_key(Pair)),
+ V = map_var(cerl:map_pair_val(Pair)),
cerl:update_c_map_pair(Pair, Op, K, V).
+map_var(Var) ->
+ case cerl:is_c_var(Var) of
+ true ->
+ case cerl:var_name(Var) of
+ Name when is_atom(Name) ->
+ L = atom_to_list(Name),
+ try list_to_integer(L) of
+ Int ->
+ cerl:update_c_var(Var, Int)
+ catch
+ error:_ ->
+ Var
+ end;
+ _ ->
+ Var
+ end;
+ false ->
+ Var
+ end.
+
%% Compile to Beam assembly language (.S) and then try to
%% run .S through the compiler again.