From 926be4d0a3a75f48bc280a7aa2f97fc4adbef189 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 1 Mar 2014 17:26:56 +0100 Subject: Do not try to optimize non-boolean guards Expressions such as erlang:'or'(bar, true) can make beam_bool crash if it tries to optimize them, as this code is not quite really written by users, no attempt to rewrite them more efficiently should be done, for simplicity's sake. Reported-by: Ulf Norell --- lib/compiler/test/andor_SUITE.erl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/compiler/test/andor_SUITE.erl') diff --git a/lib/compiler/test/andor_SUITE.erl b/lib/compiler/test/andor_SUITE.erl index 7bef0aa27c..d79696df38 100644 --- a/lib/compiler/test/andor_SUITE.erl +++ b/lib/compiler/test/andor_SUITE.erl @@ -129,6 +129,10 @@ t_case_y(X, Y, Z) -> Y =:= 100 end. +-define(GUARD(E), if E -> true; + true -> false + end). + t_and_or(Config) when is_list(Config) -> ?line true = true and true, ?line false = true and false, @@ -160,11 +164,14 @@ t_and_or(Config) when is_list(Config) -> ?line true = false or id(true), ?line false = false or id(false), - ok. + True = id(true), --define(GUARD(E), if E -> true; - true -> false - end). + false = ?GUARD(erlang:'and'(bar, True)), + false = ?GUARD(erlang:'or'(bar, True)), + false = ?GUARD(erlang:'not'(erlang:'and'(bar, True))), + false = ?GUARD(erlang:'not'(erlang:'not'(erlang:'and'(bar, True)))), + + ok. t_andalso(Config) when is_list(Config) -> Bs = [true,false], -- cgit v1.2.3