File 1151-Deprecate-old-style-catch-expressions.patch of Package erlang

From f2031d4995865030882cac5daca032f81ef4275f Mon Sep 17 00:00:00 2001
From: Richard Carlsson <carlsson.richard@gmail.com>
Date: Sat, 7 Dec 2024 21:53:56 +0100
Subject: [PATCH 1/5] Deprecate old-style catch expressions

---
 lib/stdlib/src/erl_lint.erl | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index a24142ead5..7dd991e4ab 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -592,7 +592,14 @@ format_error_1({deprecated_builtin_type, {Name, Arity},
            end,
     {~"type ~w/~w is deprecated and will be removed in ~s; use ~s",
      [Name, Arity, Rel, UseS]};
-format_error_1({not_exported_opaque, {TypeName, Arity}}) ->
+format_error_1(deprecated_catch) ->
+    ~"""
+     'catch ...' is deprecated and will be removed in a
+     future version of Erlang/OTP; please use 'try ... catch ... end' instead.
+     Compile directive 'nowarn_deprecated_catch' can be used to suppress
+     warnings in selected modules.
+     """;
+ format_error_1({not_exported_opaque, {TypeName, Arity}}) ->
     {~"opaque type ~tw~s is not exported",
                   [TypeName, gen_type_paren(Arity)]};
 format_error_1({bad_dialyzer_attribute,Term}) ->
@@ -791,6 +798,9 @@ start(File, Opts) ->
 	 {deprecated_callback,
 	  bool_option(warn_deprecated_callback, nowarn_deprecated_callback,
 		      true, Opts)},
+         {deprecated_catch,
+          bool_option(warn_deprecated_catch, nowarn_deprecated_catch,
+                      true, Opts)},
          {obsolete_guard,
           bool_option(warn_obsolete_guard, nowarn_obsolete_guard,
                       true, Opts)},
@@ -2893,7 +2903,11 @@ expr({'try',Anno,Es,Scs,Ccs,As}, Vt, St0) ->
 expr({'catch',Anno,E}, Vt, St0) ->
     %% No new variables added, flag new variables as unsafe.
     {Evt,St} = expr(E, Vt, St0),
-    {vtupdate(vtunsafe({'catch',Anno}, Evt, Vt), Evt),St};
+    St1 = case is_warn_enabled(deprecated_catch, St) of
+              true -> add_warning(Anno, deprecated_catch, St);
+              false -> St
+          end,
+    {vtupdate(vtunsafe({'catch',Anno}, Evt, Vt), Evt),St1};
 expr({match,_Anno,P,E}, Vt, St0) ->
     {Evt,St1} = expr(E, Vt, St0),
     {Pvt,Pnew,St} = pattern(P, vtupdate(Evt, Vt), St1),
-- 
2.43.0

openSUSE Build Service is sponsored by