From c221bb38a80f8c3c4263ebdd609ff8ae6e5d117f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 27 Jun 2018 13:48:21 +0200 Subject: Fix internal compiler error for map_get/2 Code such as that the following: Val = map_get(a, Map), Map#{a:=z} %Could be any map update would incorrectly cause an internal consistency check failure: Internal consistency check failed - please report this bug. Instruction: {put_map_exact,{f,0},{x,0},{x,0},1,{list,[{atom,a},{atom,z}]}} Error: {bad_type,{needed,map},{actual,term}}: Update beam_validator so that it understands that the second argument for map_get/2 is a map. --- lib/compiler/test/map_SUITE.erl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/compiler/test') diff --git a/lib/compiler/test/map_SUITE.erl b/lib/compiler/test/map_SUITE.erl index 6badc7a8b8..494faf299b 100644 --- a/lib/compiler/test/map_SUITE.erl +++ b/lib/compiler/test/map_SUITE.erl @@ -706,6 +706,12 @@ t_map_get(Config) when is_list(Config) -> {'EXIT',{{badmap,[]},_}} = (catch map_get(a, [])), {'EXIT',{{badmap,<<1,2,3>>},_}} = (catch map_get(a, <<1,2,3>>)), {'EXIT',{{badmap,1},_}} = (catch map_get(a, 1)), + + %% Test that beam_validator understands that NewMap is + %% a map after seeing map_get(a, NewMap). + NewMap = id(#{a=>b}), + b = map_get(a, NewMap), + #{a:=z} = NewMap#{a:=z}, ok. check_map_value(Map, Key, Value) when map_get(Key, Map) =:= Value -> true; -- cgit v1.2.3