diff options
author | José Valim <[email protected]> | 2013-11-22 18:44:00 +0100 |
---|---|---|
committer | José Valim <[email protected]> | 2014-01-23 10:43:14 +0100 |
commit | 2c73f41fc16fbbbbfc0fea1ee0bbd5e6038e6a54 (patch) | |
tree | 8835eda53c12fdce9ca8e2fea308365fff605e26 /lib/stdlib/src/erl_eval.erl | |
parent | 77bf7dfa0cc6d99c426d4057da8446dc51cea7aa (diff) | |
download | otp-2c73f41fc16fbbbbfc0fea1ee0bbd5e6038e6a54.tar.gz otp-2c73f41fc16fbbbbfc0fea1ee0bbd5e6038e6a54.tar.bz2 otp-2c73f41fc16fbbbbfc0fea1ee0bbd5e6038e6a54.zip |
Fix erl_eval bug when erlang:'=='/2 is used in guards
Prior to this commit, erl_eval did not properly evaluate
erlang:'=='/2 and friends in guard clauses because it
always flattened it to a local call ==/2. This commit
removes the flattening logic while still normalizing old
guards style.
Diffstat (limited to 'lib/stdlib/src/erl_eval.erl')
-rw-r--r-- | lib/stdlib/src/erl_eval.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/stdlib/src/erl_eval.erl b/lib/stdlib/src/erl_eval.erl index ca6a4b5c58..970197641f 100644 --- a/lib/stdlib/src/erl_eval.erl +++ b/lib/stdlib/src/erl_eval.erl @@ -889,12 +889,16 @@ guard0([], _Bs, _Lf, _Ef) -> true. guard_test({call,L,{atom,Ln,F},As0}, Bs0, Lf, Ef) -> TT = type_test(F), G = {call,L,{atom,Ln,TT},As0}, - try {value,true,_} = expr(G, Bs0, Lf, Ef, none) - catch error:_ -> {value,false,Bs0} end; -guard_test({call,L,{remote,_Lr,{atom,_Lm,erlang},{atom,_Lf,_F}=T},As0}, + expr_guard_test(G, Bs0, Lf, Ef); +guard_test({call,L,{remote,Lr,{atom,Lm,erlang},{atom,Lf,F}},As0}, Bs0, Lf, Ef) -> - guard_test({call,L,T,As0}, Bs0, Lf, Ef); + TT = type_test(F), + G = {call,L,{remote,Lr,{atom,Lm,erlang},{atom,Lf,TT}},As0}, + expr_guard_test(G, Bs0, Lf, Ef); guard_test(G, Bs0, Lf, Ef) -> + expr_guard_test(G, Bs0, Lf, Ef). + +expr_guard_test(G, Bs0, Lf, Ef) -> try {value,true,_} = expr(G, Bs0, Lf, Ef, none) catch error:_ -> {value,false,Bs0} end. |