aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-02-26 10:24:10 +0100
committerJohn Högberg <[email protected]>2019-02-27 11:57:24 +0100
commit1193acf4bdc1435790756e4dab1cdd91657abf94 (patch)
tree3db97a7af35fa5dabf103b4a4f70c6eb440d51e0
parent11bc38e0a5f8028be4bad1345a788656346df2e2 (diff)
downloadotp-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.erl11
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 ->