diff options
author | John Högberg <[email protected]> | 2019-02-26 10:24:10 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-02-27 11:57:24 +0100 |
commit | 1193acf4bdc1435790756e4dab1cdd91657abf94 (patch) | |
tree | 3db97a7af35fa5dabf103b4a4f70c6eb440d51e0 | |
parent | 11bc38e0a5f8028be4bad1345a788656346df2e2 (diff) | |
download | otp-1193acf4bdc1435790756e4dab1cdd91657abf94.tar.gz otp-1193acf4bdc1435790756e4dab1cdd91657abf94.tar.bz2 otp-1193acf4bdc1435790756e4dab1cdd91657abf94.zip |
beam_validator: Treat is_nil as is_eq_exact with nil
-rw-r--r-- | lib/compiler/src/beam_validator.erl | 11 |
1 files changed, 10 insertions, 1 deletions
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 -> |