From 1193acf4bdc1435790756e4dab1cdd91657abf94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Tue, 26 Feb 2019 10:24:10 +0100 Subject: beam_validator: Treat is_nil as is_eq_exact with nil --- lib/compiler/src/beam_validator.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index 0d8ab3739c..f848b4de8d 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -779,7 +779,16 @@ valfun_4({test,is_nonempty_list,{f,Lbl},[Src]}, Vst) -> valfun_4({test,is_list,{f,Lbl},[Src]}, Vst) -> type_test(Lbl, list, Src, Vst); valfun_4({test,is_nil,{f,Lbl},[Src]}, Vst) -> - type_test(Lbl, nil, Src, Vst); + %% is_nil is an exact check against the 'nil' value, and should not be + %% treated as a simple type test. + assert_term(Src, Vst), + complex_test(Lbl, + fun(FailVst) -> + update_ne_types(Src, nil, FailVst) + end, + fun(SuccVst) -> + update_eq_types(Src, nil, SuccVst) + end, Vst); valfun_4({test,is_map,{f,Lbl},[Src]}, Vst) -> case Src of {Tag,_} when Tag =:= x; Tag =:= y -> -- cgit v1.2.3