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

Fix specs introduced with Mod:module_info/1,2 support #498

Merged
merged 1 commit into from
Dec 17, 2022
Merged
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
4 changes: 2 additions & 2 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5112,7 +5112,7 @@ record_field_types(Fields) ->
end, Fields).

% Helper returning the type of module_info/0 and module_info/1 functions
-spec get_module_info_type(arity()) -> fun_ty().
-spec get_module_info_type(arity()) -> type() | [type()].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an two-clause spec (0) -> type(); (1) -> [type()] here?

Copy link
Collaborator

@zuiderkwast zuiderkwast Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, what happens if some code contains a call to module_info/N where N > 1? Do we crash?

get_module_info_type(0) ->
Options = get_module_info_options(),
DefaultKeys = [module, attributes, compile, exports, md5, native],
Expand All @@ -5123,7 +5123,7 @@ get_module_info_type(1) ->
Options = get_module_info_options(),
lists:map(fun ({Key, Type}) -> type_fun([type_atom(Key)], Type) end, Options).

-spec get_module_info_options() -> #{atom() => type()}.
-spec get_module_info_options() -> [{atom(), type()}].
get_module_info_options() ->
[
{module, type(module)},
Expand Down