From 55e4051bbe8f9790e19cf403bdd736a56e512510 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 5 Mar 2014 00:00:01 +0100 Subject: Properly check label use in get_map_elements in beam_jump Reported-by: Ulf Norell --- lib/compiler/src/beam_jump.erl | 1 + lib/compiler/test/map_SUITE.erl | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl index 0fc8d45c80..100acaede3 100644 --- a/lib/compiler/src/beam_jump.erl +++ b/lib/compiler/src/beam_jump.erl @@ -451,6 +451,7 @@ is_label_used_in_2({set,_,_,Info}, Lbl) -> {put_tuple,_} -> false; {get_tuple_element,_} -> false; {set_tuple_element,_} -> false; + {get_map_elements,{f,F}} -> F =:= Lbl; {line,_} -> false; _ when is_atom(Info) -> false end. diff --git a/lib/compiler/test/map_SUITE.erl b/lib/compiler/test/map_SUITE.erl index 3639192a51..427883d59b 100644 --- a/lib/compiler/test/map_SUITE.erl +++ b/lib/compiler/test/map_SUITE.erl @@ -293,6 +293,8 @@ t_guard_bifs(Config) when is_list(Config) -> false = map_guard_body({}), true = map_guard_pattern(#{a=>1, <<"hi">> => "hi" }), false = map_guard_pattern("list"), + true = map_guard_tautology(), + true = map_guard_ill_map_size(), ok. map_guard_empty() when is_map(#{}); false -> true. @@ -305,6 +307,10 @@ map_guard_body(M) -> is_map(M). map_guard_pattern(#{}) -> true; map_guard_pattern(_) -> false. +map_guard_tautology() when #{} =:= #{}; true -> true. + +map_guard_ill_map_size() when true; map_size(0) -> true. + t_guard_sequence(Config) when is_list(Config) -> {1, "a"} = map_guard_sequence_1(#{seq=>1,val=>id("a")}), {2, "b"} = map_guard_sequence_1(#{seq=>2,val=>id("b")}), -- cgit v1.2.3