From f9ea85611faca82c7494449ddb8bcb1ef1d194cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 17 Jan 2019 10:42:41 +0100 Subject: Make the beam_validator smarter (again) Needed because of the optimizations in 48f20bd589fa69. https://bugs.erlang.org/browse/ERL-832 --- lib/compiler/src/beam_validator.erl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lib/compiler/src') diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index 46c689e034..3d53054f69 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -828,13 +828,14 @@ valfun_4({test,is_map,{f,Lbl},[Src]}, Vst0) -> _ -> kill_state(Vst0) end; -valfun_4({test,is_nil,{f,Lbl},[Src]}, Vst) -> - case get_term_type(Src, Vst) of - list -> - branch_state(Lbl, set_type_reg(cons, Src, Vst)); - _ -> - branch_state(Lbl, Vst) - end; +valfun_4({test,is_nil,{f,Lbl},[Src]}, Vst0) -> + Vst = case get_term_type(Src, Vst0) of + list -> + branch_state(Lbl, set_type_reg(cons, Src, Vst0)); + _ -> + branch_state(Lbl, Vst0) + end, + set_aliased_type(nil, Src, Vst); valfun_4({test,is_eq_exact,{f,Lbl},[Src,Val]=Ss}, Vst0) -> validate_src(Ss, Vst0), Infer = infer_types(Src, Vst0), @@ -1903,6 +1904,10 @@ merge_types({atom,A}, bool) -> merge_bool(A); merge_types(cons, {literal,[_|_]}) -> cons; +merge_types(cons, nil) -> + list; +merge_types(nil, cons) -> + list; merge_types({literal,[_|_]}, cons) -> cons; merge_types({literal,[_|_]}, {literal,[_|_]}) -> -- cgit v1.2.3