Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate old catch #9154

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/compiler/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
# FLAGS
# ----------------------------------------------------

ERL_COMPILE_FLAGS += -Werror
ERL_COMPILE_FLAGS += -Werror +warn_deprecated_catch
ERL_COMPILE_FLAGS += +inline +warn_unused_import \
-I../../stdlib/include -I$(EGEN) -W +warn_missing_spec

Expand Down
6 changes: 6 additions & 0 deletions lib/compiler/src/compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,12 @@ value are listed.
Default is to emit warnings for every use of a callback known by the compiler to
be deprecated.

- **`warn_deprecated_catch`** - Enables warnings for use of old style catch
expressions on the form `catch Expr` instead of the modern `try ... catch
... end`. You may enable this compiler option on the project level and
add `-compile(nowarn_deprecated_catch).` to individual files which still
contain old catches in order to prevent new uses from getting added.

- **`nowarn_removed`** - Turns off warnings for calls to functions that have
been removed. Default is to emit warnings for every call to a function known
by the compiler to have been recently removed from Erlang/OTP.
Expand Down
2 changes: 2 additions & 0 deletions lib/compiler/src/core_scan.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
-module(core_scan).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-export([string/1, string/2, format_error/1]).

-import(lists, [reverse/1]).
Expand Down
2 changes: 1 addition & 1 deletion lib/kernel/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
# FLAGS
# ----------------------------------------------------

ERL_COMPILE_FLAGS += -Werror
ERL_COMPILE_FLAGS += -Werror +warn_deprecated_catch
ERL_COMPILE_FLAGS += -I../include


Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/application_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(application_controller).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% External exports
-export([start/1,
load_application/1, unload_application/1,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/application_master.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(application_master).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% External exports
-export([start_link/2, start_type/0, stop/1]).
-export([get_child/1]).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/application_starter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
-module(application_starter).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-export([start/3]).

%%%=============================================================================
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Manual.
-moduledoc(#{ deprecated => ~"See each function for what to use instead" }).
-behaviour(gen_server).

-compile(nowarn_deprecated_catch).

-export([start_link/0]).

%% Old documented interface - deprecated
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/code.erl
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ common reasons.
- **`sticky_directory`** - The object code resides in a sticky directory.
""".

-compile(nowarn_deprecated_catch).

-include_lib("kernel/include/logger.hrl").
-include("eep48.hrl").

Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/code_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(code_server).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% This file holds the server part of the code_server.

-export([start_link/1,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/disk_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Nothing is said about whether the disk log files exist or not.
`m:file`, `m:wrap_log_reader`
""".

-compile(nowarn_deprecated_catch).

%% Efficient file based log - process part

-export([start/0, istart_link/1,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/disk_log_1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(disk_log_1).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% Efficient file based log - implementation part

-export([int_open/4, ext_open/4, logl/1, close/3, truncate/3, chunk/5,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/dist_ac.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(dist_ac).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-behaviour(gen_server).

%% External exports
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/erl_boot_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ and `m:erl_prim_loader` in ERTS.
[`erts:init`](`m:init`), [`erts:erl_prim_loader`](`m:erl_prim_loader`)
""".

-compile(nowarn_deprecated_catch).

-include("inet_boot.hrl").

-behaviour(gen_server).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/erl_ddll.erl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ follows:
[`erl_driver(4)`](`e:erts:erl_driver.md`), [`driver_entry(4)`](`e:erts:driver_entry.md`)
""".

-compile(nowarn_deprecated_catch).

-export([load_driver/2, load/2,
unload_driver/1, unload/1, reload/2, reload_driver/2,
format_error/1,info/1,info/0, start/0, stop/0]).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/erl_epmd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ To implement your own epmd module please see
""".
-moduledoc(#{since => "OTP R14B"}).

-compile(nowarn_deprecated_catch).

-behaviour(gen_server).

-ifdef(DEBUG).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/file_io_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(file_io_server).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% A simple file server for io to one file instance per server instance.

-export([format_error/1]).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/file_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
-module(file_server).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-behaviour(gen_server).

%% External exports
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/gen_tcp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ way, option `send_timeout` comes in handy.
""".


-compile(nowarn_deprecated_catch).

-export([connect/2, connect/3, connect/4,
listen/2,
accept/1, accept/2,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/gen_udp_socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
-moduledoc false.
-behaviour(gen_statem).

-compile(nowarn_deprecated_catch).

-compile({no_auto_import, [monitor/1]}).

%% gen_udp
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/global.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ network problem.
""".
-behaviour(gen_server).

-compile(nowarn_deprecated_catch).

%% Global provides global registration of process names. The names are
%% dynamically kept up to date with the entire network. Global can
%% operate in two modes: in a fully connected network, or in a
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/global_group.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ global group as the local node.
`m:global`, [`erl`](`e:erts:erl_cmd.md`)
""".

-compile(nowarn_deprecated_catch).

%% Groups nodes into global groups with an own global name space.

-behaviour(gen_server).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/group.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(group).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-include_lib("kernel/include/logger.hrl").

%% A group leader process for user io.
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/heart.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ In the following descriptions, all functions fail with reason `badarg` if
`heart` is not started.
""".

-compile(nowarn_deprecated_catch).

%%%--------------------------------------------------------------------
%%% This is a rewrite of pre_heart from BS.3.
%%%
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/inet_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(inet_config).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-include("inet_config.hrl").
-include("inet.hrl").

Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/inet_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
-module(inet_db).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% Store info about ip addresses, names, aliases host files resolver
%% options.
%% Also miscellaneous "stuff" related to sockets.
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/inet_gethost_native.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
-moduledoc false.
-behaviour(supervisor_bridge).

-compile(nowarn_deprecated_catch).

%% Supervisor bridge exports
-export([start_link/0, init/1, terminate/2]).

Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/inet_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(inet_parse).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% Parser for all kinds of ineternet configuration files

%% Avoid warning for local function error/2 clashing with autoimported BIF.
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/kernel_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(kernel_config).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-behaviour(gen_server).

%% External exports
Expand Down
3 changes: 3 additions & 0 deletions lib/kernel/src/net_adm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ _Example:_
^ (new line)
```
""".

-compile(nowarn_deprecated_catch).

-export([host_file/0,
localhost/0,
names/0, names/1,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/net_kernel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ in the Erlang Reference Manual.
> for details on how to setup a secure distributed node.
""".

-compile(nowarn_deprecated_catch).

-behaviour(gen_server).

-define(nodedown(N, State), verbose({?MODULE, ?LINE, nodedown, N}, 1, State)).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/os.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ a program to run on most platforms.
> Types" section.
""".

-compile(nowarn_deprecated_catch).

%% Provides a common operating system interface.

-export([type/0, version/0, cmd/1, cmd/2, find_executable/1, find_executable/2]).
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/rpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ some specific side effects on the remote node.

-behaviour(gen_server).

-compile(nowarn_deprecated_catch).

-export([start/0, start_link/0, stop/0,
call/4, call/5,
block_call/4, block_call/5,
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/standard_error.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
-moduledoc false.
-behaviour(supervisor_bridge).

-compile(nowarn_deprecated_catch).

-include_lib("kernel/include/logger.hrl").

%% Basic standard i/o server for standard_error.
Expand Down
2 changes: 2 additions & 0 deletions lib/kernel/src/wrap_log_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ logged items in the log file, as the opened index file was truncated by
-define(FORMAT(P, A), ok).
-endif.

-compile(nowarn_deprecated_catch).

-export([open/1, open/2, chunk/1, chunk/2, close/1]).

-export_type([continuation/0]).
Expand Down
2 changes: 1 addition & 1 deletion lib/stdlib/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ endif
# FLAGS
# ----------------------------------------------------

ERL_COMPILE_FLAGS += -Werror
ERL_COMPILE_FLAGS += -Werror +warn_deprecated_catch
ERL_COMPILE_FLAGS += -I../include -I../../kernel/include

ifeq ($(ERL_DETERMINISTIC),yes)
Expand Down
2 changes: 2 additions & 0 deletions lib/stdlib/src/beam_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ providing one key for module `t` and another key for all other modules:
""".
-behaviour(gen_server).

-compile(nowarn_deprecated_catch).

-include_lib("kernel/include/eep48.hrl").

%% Avoid warning for local function error/1 clashing with autoimported BIF.
Expand Down
2 changes: 2 additions & 0 deletions lib/stdlib/src/c.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ commands.
`m:filename`, `m:compile`, `m:erlang`, `m:yecc`, `m:xref`
""".

-compile(nowarn_deprecated_catch).

-include_lib("kernel/include/eep48.hrl").

%% Utilities to use from shell.
Expand Down
2 changes: 2 additions & 0 deletions lib/stdlib/src/dets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ message.
`m:ets`, `m:mnesia`, `m:qlc`
""".

-compile(nowarn_deprecated_catch).

%% Disk based linear hashing lookup dictionary.

%% Public.
Expand Down
2 changes: 2 additions & 0 deletions lib/stdlib/src/dets_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
-module(dets_utils).
-moduledoc false.

-compile(nowarn_deprecated_catch).

%% Utility functions common to several dets file formats.
%% To be used from modules dets and dets_v9 only.

Expand Down
2 changes: 2 additions & 0 deletions lib/stdlib/src/dets_v9.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
-moduledoc false.
-compile([{nowarn_deprecated_function, [{erlang,phash,2}]}]).

-compile(nowarn_deprecated_catch).

%% Dets files, implementation part. This module handles version 9.
%% To be called from dets.erl only.

Expand Down
2 changes: 2 additions & 0 deletions lib/stdlib/src/edlin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ supports multiple lines.
""".
-moduledoc(#{since => "OTP 26.1"}).

-compile(nowarn_deprecated_catch).

%% A simple Emacs-like line editor.
%% About Latin-1 characters: see the beginning of erl_scan.erl.

Expand Down
3 changes: 3 additions & 0 deletions lib/stdlib/src/edlin_type_suggestion.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
%%
-module(edlin_type_suggestion).
-moduledoc false.

-compile(nowarn_deprecated_catch).

-include_lib("kernel/include/eep48.hrl").
-export([type_tree/4, get_arity/3, get_atoms/3, get_types/3, get_types/4, get_function_type/4, print_type/3]).

Expand Down
Loading
Loading