File 0489-v3_core-Fix-wrapping-of-float-1-call.patch of Package erlang

From 5b0fad5f9f13a6001d9e98f8ecab43fede191788 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Thu, 12 Sep 2019 07:55:09 +0200
Subject: [PATCH 1/4] 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.
---
 lib/compiler/src/v3_core.erl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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};
-- 
2.16.4

openSUSE Build Service is sponsored by