From 131ff5fac7da80fe8080425182bf29f673ab301c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 19 Oct 2018 05:52:19 +0200 Subject: beam_lib: Remove obsolete module() from the beam() type The type `beam()` in the `beam_lib` module is confusing: -type beam() :: module() | file:filename() | binary(). It says that the module name can be used to identify the BEAM module to be accessed, but passing in the module name only works if the BEAM file is located in the current working directory because the module is not searched for in the code path. The reason that it is allowed to pass in the module name as an atom is for backward compatibility. A long time ago, atoms instead of strings were used as filenames. For that reason, `filename` and `file` still accept atoms as filenames (although the practice is frown upon). `beam_lib` accepts an atom as the filename for the same reason. To remove the confusion, remove `module()` from the type and the mention of it in the documentation. Code that uses an atom as a filename will still work, but Dialyzer will issue a warning. https://bugs.erlang.org/browse/ERL-696 --- lib/stdlib/doc/src/beam_lib.xml | 4 ++-- lib/stdlib/src/beam_lib.erl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/doc/src/beam_lib.xml b/lib/stdlib/doc/src/beam_lib.xml index 26d0724aaf..213170df7f 100644 --- a/lib/stdlib/doc/src/beam_lib.xml +++ b/lib/stdlib/doc/src/beam_lib.xml @@ -180,8 +180,8 @@ io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).

Each of the functions described below accept either the - module name, the filename, or a binary containing the BEAM - module.

+ filename (as a string) or a binary containing the BEAM + module.

diff --git a/lib/stdlib/src/beam_lib.erl b/lib/stdlib/src/beam_lib.erl index 01181b1097..3386cfcbe6 100644 --- a/lib/stdlib/src/beam_lib.erl +++ b/lib/stdlib/src/beam_lib.erl @@ -53,7 +53,7 @@ %%------------------------------------------------------------------------- --type beam() :: module() | file:filename() | binary(). +-type beam() :: file:filename() | binary(). -type debug_info() :: {DbgiVersion :: atom(), Backend :: module(), Data :: term()} | 'no_debug_info'. -type forms() :: [erl_parse:abstract_form() | erl_parse:form_info()]. -- cgit v1.2.3