File 2593-stdlib-Correct-pretty-printing-of-throw.patch of Package erlang

From ec4bc1c065e086ab4d048eaf66ce350ff9521edf Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Wed, 29 Jan 2020 09:33:51 +0100
Subject: [PATCH 3/5] stdlib: Correct pretty-printing of 'throw'

The correction in 0682f0 was erroneously removed in 4090af.
---
 lib/stdlib/src/erl_pp.erl        |  6 -----
 lib/stdlib/test/erl_pp_SUITE.erl | 58 +++++++++++++++++++---------------------
 2 files changed, 28 insertions(+), 36 deletions(-)

diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl
index 2d2defc344..4f0609efb7 100644
--- a/lib/stdlib/src/erl_pp.erl
+++ b/lib/stdlib/src/erl_pp.erl
@@ -842,12 +842,6 @@ cr_clause({clause,_,[T],G,B}, Opts) ->
 try_clauses(Cs, Opts) ->
     clauses(fun try_clause/2, Opts, Cs).
 
-try_clause({clause,_,[{tuple,_,[{atom,_,throw},V,S]}],G,B}, Opts) ->
-    El = lexpr(V, 0, Opts),
-    Sl = stack_backtrace(S, [El], Opts),
-    Gl = guard_when(Sl, G, Opts),
-    Bl = body(B, Opts),
-    {step,Gl,Bl};
 try_clause({clause,_,[{tuple,_,[C,V,S]}],G,B}, Opts) ->
     Cs = lexpr(C, 0, Opts),
     El = lexpr(V, 0, Opts),
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index 647279cdf1..f341e3a7bf 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1190,36 +1190,34 @@ otp_15592(_Config) ->
     ok.
 
 otp_15751(_Config) ->
-    ok = pp_expr(<<"try foo:bar()
-                        catch
-                            Reason : Stacktrace ->
-                                {Reason, Stacktrace}
-                    end">>),
-    ok = pp_expr(<<"try foo:bar()
-                        catch
-                            throw: Reason : Stacktrace ->
-                                {Reason, Stacktrace}
-                    end">>),
-    ok = pp_expr(<<"try foo:bar()
-                        catch
-                            Reason : _ ->
-                                Reason
-                    end">>),
-    ok = pp_expr(<<"try foo:bar()
-                        catch
-                            throw: Reason : _ ->
-                                Reason
-                    end">>),
-    ok = pp_expr(<<"try foo:bar()
-                        catch
-                            Reason ->
-                                Reason
-                    end">>),
-    ok = pp_expr(<<"try foo:bar()
-                        catch
-                            throw: Reason ->
-                                Reason
-                    end">>),
+    Check = fun(L) ->
+                    ok = pp_expr(L),
+                    remove_indentation(flat_parse_and_pp_expr(L, 0, []))
+            end,
+    "try foo:bar() catch Reason:Stacktrace -> {Reason, Stacktrace} end" =
+        Check("try foo:bar()
+           catch Reason:Stacktrace -> {Reason, Stacktrace}  end"),
+
+    "try foo:bar() catch throw:Reason:Stacktrace -> {Reason, Stacktrace} end" =
+        Check("try foo:bar()
+           catch throw:Reason:Stacktrace -> {Reason, Stacktrace} end"),
+
+    "try foo:bar() catch Reason:_ -> Reason end" =
+        Check("try foo:bar()
+           catch Reason:_ -> Reason end"),
+
+    "try foo:bar() catch throw:Reason -> Reason end" = % ":_" removed
+        Check("try foo:bar()
+           catch throw:Reason:_-> Reason end"),
+
+    "try foo:bar() catch throw:Reason -> Reason end" = % "throw:" added
+        Check("try foo:bar()
+           catch Reason -> Reason end"),
+
+    "try foo:bar() catch throw:Reason -> Reason end" =
+        Check("try foo:bar()
+           catch throw:Reason -> Reason end"),
+
     ok.
 
 otp_15755(_Config) ->
-- 
2.16.4

openSUSE Build Service is sponsored by