File 2598-stdlib-Correct-pretty-printing-of-erlang-float-1.patch of Package erlang
From 6fcf0d7ae1fa376a20b2aebc75a4e7c8c38d06ac Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Thu, 27 Feb 2020 16:23:17 +0100
Subject: [PATCH] stdlib: Correct pretty printing of erlang:float/1
Printing "erlang:float(X)" as "float(X)" would change the meaning of a
guard.
---
lib/stdlib/src/erl_pp.erl | 4 +++-
lib/stdlib/test/erl_pp_SUITE.erl | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl
index c706a5c945..387fa395ce 100644
--- a/lib/stdlib/src/erl_pp.erl
+++ b/lib/stdlib/src/erl_pp.erl
@@ -652,8 +652,10 @@ lexpr({named_fun,_,Name,Cs,Extra}, _Prec, Opts) ->
{reserved,'end'}]}};
lexpr({call,_,{remote,_,{atom,_,M},{atom,_,F}=N}=Name,Args}, Prec, Opts) ->
case erl_internal:bif(M, F, length(Args)) of
- true ->
+ true when F =/= float ->
call(N, Args, Prec, Opts);
+ true ->
+ call(Name, Args, Prec, Opts);
false ->
call(Name, Args, Prec, Opts)
end;
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index 61eccdd1b5..4edecdb8c3 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1305,7 +1305,7 @@ otp_16435(_Config) ->
CheckF("f() ->\n << \n (catch <<1:4>>) ||\n"
" A <- []\n >>.\n"),
CheckF("f() ->\n [ \n (catch foo) ||\n A <- []\n ].\n"),
-
+ CheckF("f() when erlang:float(3.0) ->\n true.\n"),
Check = fun(S) -> S = flat_parse_and_pp_expr(S, 0, []) end,
Check("5 #r4.f1"),
--
2.16.4