diff options
author | Björn Gustavsson <[email protected]> | 2015-08-10 06:25:00 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-08-21 15:56:14 +0200 |
commit | e92ad3c4d6358cecbba7643ccc14610957ad79ab (patch) | |
tree | fdb7fd028a986a41e7aa8db43f05b09b31337300 /lib/compiler/src/beam_validator.erl | |
parent | f63b503f9c7ea4d5824899dc5b287075e261e6a8 (diff) | |
download | otp-e92ad3c4d6358cecbba7643ccc14610957ad79ab.tar.gz otp-e92ad3c4d6358cecbba7643ccc14610957ad79ab.tar.bz2 otp-e92ad3c4d6358cecbba7643ccc14610957ad79ab.zip |
v3_core: Improve code generation for guards
When translating guards to Core Erlang, it is sometimes necessary
to add an is_boolean/1 guard test. Here is an example when it is
necessary:
o(A, B) when A or B ->
ok.
That would be translated to something like:
o(A, B) when ((A =:= true) or (B =:= true)) and
is_boolean(A) and is_boolean(B) ->
ok.
The is_boolean/1 tests are necessary to ensure that the guard
fails for calls such as:
o(true, not_boolean)
However, because of a bug in v3_core, is_boolean/1 tests were
added when they were not necessary. Here is an example:
f(B) when not B -> ok.
That would be translated to:
f(B) when (B =:= false) and is_boolean(B) -> ok.
The following translation will work just as well.
f(B) when B =:= false -> ok.
Correct the bug to suppress those unnecessary is_boolean/1 tests.
Diffstat (limited to 'lib/compiler/src/beam_validator.erl')
0 files changed, 0 insertions, 0 deletions