Skip to content

Commit

Permalink
Deprecate old-style catch expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
richcarl committed Dec 7, 2024
1 parent fcf7c06 commit a36ea43
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/stdlib/src/erl_lint.erl
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@ 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(deprecated_catch) ->
~"""
'catch ...' is deprecated and will be removed in a future version of Erlang/OTP
please use 'try ... catch ... end' instead
""";
format_error_1({not_exported_opaque, {TypeName, Arity}}) ->
{~"opaque type ~tw~s is not exported",
[TypeName, gen_type_paren(Arity)]};
Expand Down Expand Up @@ -2823,7 +2828,8 @@ 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 = add_warning(Anno, deprecated_catch, St),
{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),
Expand Down

0 comments on commit a36ea43

Please sign in to comment.