diff options
author | Björn Gustavsson <bjorn@erlang.org> | 2019-09-12 07:55:09 +0200 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2019-09-13 14:21:52 +0200 |
commit | 5b0fad5f9f13a6001d9e98f8ecab43fede191788 (patch) | |
tree | 8190ab0a5a29d9780a9649644361237904888d33 | |
parent | 2b02135970b3f6ec9e02eb6cbc2643d81446a72f (diff) | |
download | erlang-5b0fad5f9f13a6001d9e98f8ecab43fede191788.tar.gz |
v3_core: Fix wrapping of float/1 call
When translating guards, any calls to BIFs that are not known
to always return booleans should be wrapped in a comparison
with `true`. This was not done for `float/1` BIF (as a conversion
function, not the obsolete type test). Here is an example of
a function where the `float/1` calls were not wrapped:
foo(X) when float(X) or float(X) -> ok.
Not wrapping `float/1` happens to be harmless, but is an
annyoing inconsistency.
With the correction, the guard will be rewritten like this
during the translatation to Core Erlang:
foo(X) when (float(X) =:= true) or (float(X) =:= true) -> ok.
-rw-r--r-- | lib/compiler/src/v3_core.erl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index 007a0247f4..68da63299d 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -420,8 +420,11 @@ gexpr_test(E0, Bools0, St0) -> %% Generate "top-level" test and argument calls. case E1 of #icall{anno=Anno,module=#c_literal{val=erlang},name=#c_literal{val=N},args=As} -> + %% Note that erl_expand_records has renamed type + %% tests to the new names; thus, float/1 as a type + %% test will now be named is_float/1. Ar = length(As), - case erl_internal:type_test(N, Ar) orelse + case erl_internal:new_type_test(N, Ar) orelse erl_internal:comp_op(N, Ar) orelse erl_internal:bool_op(N, Ar) of true -> {E1,Eps0,Bools0,St1}; |