From 31562b636b1c89595c2bb4bb81bc7f781e6bd269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 19 Oct 2018 13:01:41 +0200 Subject: hipe: Don't use beam_lib:info/1 with an atom as filename --- lib/hipe/main/hipe.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hipe/main/hipe.erl b/lib/hipe/main/hipe.erl index ac2e6c1e3b..e2cb9c0f0b 100644 --- a/lib/hipe/main/hipe.erl +++ b/lib/hipe/main/hipe.erl @@ -542,7 +542,7 @@ file(File) -> | {'error', term()} when Mod :: mod(). file(File, Options) when is_atom(File) -> - case beam_lib:info(File) of + case beam_lib:info(atom_to_list(File)) of L when is_list(L) -> {module, Mod} = lists:keyfind(module, 1, L), case compile(Mod, File, Options) of -- cgit v1.2.3 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(-) 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