From e2ba1311d8c7de4901d0296b3508c623ce9538e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 6 Mar 2019 10:14:27 +0100 Subject: beam_validator: Express test_arity/is_tagged_tuple as type tests This ensures that unreachable branches are properly ignored on repeated checks (although tuple type subtraction isn't complete yet). --- lib/compiler/src/beam_validator.erl | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index de1a87039b..ab8caa1a0d 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -902,18 +902,12 @@ valfun_4({test,is_nil,{f,Lbl},[Src]}, Vst) -> end); valfun_4({test,test_arity,{f,Lbl},[Tuple,Sz]}, Vst) when is_integer(Sz) -> assert_type(tuple, Tuple, Vst), - branch(Lbl, Vst, - fun(SuccVst) -> - Type = {tuple, Sz, #{}}, - update_type(fun meet/2, Type, Tuple, SuccVst) - end); + Type = {tuple, Sz, #{}}, + type_test(Lbl, Type, Tuple, Vst); valfun_4({test,is_tagged_tuple,{f,Lbl},[Src,Sz,Atom]}, Vst) -> assert_term(Src, Vst), - branch(Lbl, Vst, - fun(SuccVst) -> - Type = {tuple, Sz, #{ {integer,1} => Atom }}, - update_type(fun meet/2, Type, Src, SuccVst) - end); + Type = {tuple, Sz, #{ {integer,1} => Atom }}, + type_test(Lbl, Type, Src, Vst); valfun_4({test,is_eq_exact,{f,Lbl},[Src,Val]=Ss}, Vst) -> validate_src(Ss, Vst), branch(Lbl, Vst, -- cgit v1.2.3