Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Properly detect reused boolean values in beam_bool #279

Merged
merged 1 commit into from

4 participants

@nox
nox commented

The following code could crash the compiler:

f(X = true) when X or true or X -> ok.

@UlfNorell

@nox nox Properly detect reused boolean values in beam_bool
The following code could crash the compiler:

	f(X = true) when X or true or X -> ok.

Reported-by: Ulf Norell
3abbbee
@psyeugenic
Owner

Curious, if you work by day and fix compiler bugs by night .. when do you sleep? =)

@nox
nox commented

Well… I don't begin work until 11am so... =)

@nox
nox commented

Also, shouldn't you be sleeping yourself? :D

@psyeugenic
Owner

Reading up on white papers and watching Factory SF via Twitter .. but yeah =)

@nox
nox commented

The real factory is on #erlounge :p

Guess I won't make any new PR tonight, the only remaining bug @UlfNorell reported not related to arbitrary map keys is the liveness analysis one, that one looks like a complete pain =)

@bjorng bjorng was assigned by psyeugenic
@bjorng
Collaborator

Thanks! Included in our daily builds.

@proxyles proxyles merged commit 3abbbee into erlang:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 8, 2014
  1. @nox

    Properly detect reused boolean values in beam_bool

    nox authored
    The following code could crash the compiler:
    
    	f(X = true) when X or true or X -> ok.
    
    Reported-by: Ulf Norell
This page is out of date. Refresh to see the latest.
View
7 lib/compiler/src/beam_bool.erl
@@ -438,9 +438,10 @@ bopt_bool_args(As, Forest) ->
mapfoldl(fun bopt_bool_arg/2, Forest, As).
bopt_bool_arg({T,_}=R, Forest) when T =:= x; T =:= y; T =:= tmp ->
- Val = case gb_trees:get(R, Forest) of
- any -> {test,is_eq_exact,fail,[R,{atom,true}]};
- Val0 -> Val0
+ Val = case gb_trees:lookup(R, Forest) of
+ {value,any} -> {test,is_eq_exact,fail,[R,{atom,true}]};
+ {value,Val0} -> Val0;
+ none -> throw(mixed)
end,
{Val,gb_trees:delete(R, Forest)};
bopt_bool_arg(Term, Forest) ->
View
2  lib/compiler/test/andor_SUITE.erl
@@ -171,6 +171,8 @@ t_and_or(Config) when is_list(Config) ->
false = ?GUARD(erlang:'not'(erlang:'and'(bar, True))),
false = ?GUARD(erlang:'not'(erlang:'not'(erlang:'and'(bar, True)))),
+ true = (fun (X = true) when X or true or X -> true end)(True),
+
ok.
t_andalso(Config) when is_list(Config) ->
Something went wrong with that request. Please try again.