File 2592-stdlib-Fix-precedence-bug-regarding-lc-bc-template.patch of Package erlang

From bd84ae797562c03e838baea4bb48244abffe1a5e Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Tue, 28 Jan 2020 16:05:42 +0100
Subject: [PATCH 2/5] stdlib: Fix precedence bug regarding lc/bc template

---
 lib/stdlib/src/erl_pp.erl        | 6 ++++--
 lib/stdlib/test/erl_pp_SUITE.erl | 5 +++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl
index f6a84412b7..2d2defc344 100644
--- a/lib/stdlib/src/erl_pp.erl
+++ b/lib/stdlib/src/erl_pp.erl
@@ -541,11 +541,13 @@ lexpr({nil,_}, _, _) -> '[]';
 lexpr({cons,_,H,T}, _, Opts) ->
     list(T, [H], Opts);
 lexpr({lc,_,E,Qs}, _Prec, Opts) ->
-    Lcl = {list,[{step,[lexpr(E, Opts),leaf(" ||")],lc_quals(Qs, Opts)}]},
+    P = max_prec(),
+    Lcl = {list,[{step,[lexpr(E, P, Opts),leaf(" ||")],lc_quals(Qs, Opts)}]},
     {list,[{seq,$[,[],[[]],[{force_nl,leaf(" "),[Lcl]}]},$]]};
     %% {list,[{step,$[,Lcl},$]]};
 lexpr({bc,_,E,Qs}, _Prec, Opts) ->
-    Lcl = {list,[{step,[lexpr(E, Opts),leaf(" ||")],lc_quals(Qs, Opts)}]},
+    P = max_prec(),
+    Lcl = {list,[{step,[lexpr(E, P, Opts),leaf(" ||")],lc_quals(Qs, Opts)}]},
     {list,[{seq,'<<',[],[[]],[{force_nl,leaf(" "),[Lcl]}]},'>>']};
     %% {list,[{step,'<<',Lcl},'>>']};
 lexpr({tuple,_,Elts}, _, Opts) ->
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index e6ff141b5f..647279cdf1 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1271,6 +1271,11 @@ otp_16435(_Config) ->
     CheckF("-record(r,{f = 3 :: {A :: (B :: integer())}}).\n"),
     CheckF("-type t() :: #r{f :: A :: (B :: integer())}.\n"),
     CheckF("-spec t(X) -> X when X :: Y :: (Z :: #r{}).\n"),
+
+    CheckF("f() ->\n    << \n      (catch <<1:4>>) ||\n"
+           "          A <- []\n    >>.\n"),
+    CheckF("f() ->\n    [ \n     (catch foo) ||\n         A <- []\n    ].\n"),
+
     ok.
 
 gh_5093(_Config) ->
-- 
2.16.4

openSUSE Build Service is sponsored by