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

ERL-62: erl_lint:module leads to invalid call to is_builtin for some inputs with no module attribute #3208

Closed
OTP-Maintainer opened this issue Dec 22, 2015 · 1 comment
Assignees
Labels
bug Issue is reported as a bug priority:low team:VM Assigned to OTP team VM
Milestone

Comments

@OTP-Maintainer
Copy link

Original reporter: sparr
Affected version: OTP-18.0
Fixed in version: OTP-18.3
Component: stdlib
Migrated from: https://bugs.erlang.org/browse/ERL-62


If erl_lint:module is called on a set of forms that has a -deprecated line but no -module line then it ends up trying to call is_builtin with an empty list for the Module parameter, and that doesn't go so well.

test case:
{code:erlang}
-module(erl_bug).
-export([test/0,test/1]).

test() ->
    test("-module(bug_test). t()->1. t()->2."),
    test("-module(bug_test). -deprecated([{frutt,0,next_version}])."),
    test("-deprecated([{frutt,0,next_version}]).").

test(S) ->
    file:write_file("bug_test.erl",S),
    {ok, Forms} = epp:parse_file("bug_test.erl",[]),
    {error, Errors, _} = erl_lint:module(Forms, "bug_test.erl"),
    [{_,[{_,Mod,Err}]}] = Errors,
    io:fwrite("~p~n",[Err]),
    io:fwrite("~s~n",[Mod:format_error(Err)]).
{code}

result:
{code:erlang}
> erl_bug:test().
{redefine_function,{t,0}}
function t/0 already defined
{bad_deprecated,{frutt,0}}
deprecated function frutt/0 undefined or not exported
** exception error: bad argument
     in function  erlang:is_builtin/3
        called as erlang:is_builtin([],frutt,0)
     in call from erl_lint:depr_fa/4 (erl_lint.erl, line 1000)
     in call from erl_lint:'-check_deprecated/2-lc$^1/1-1-'/5 (erl_lint.erl, line 971)
     in call from erl_lint:check_deprecated/2 (erl_lint.erl, line 969)
     in call from erl_lint:post_traversal_check/2 (erl_lint.erl, line 842)
     in call from erl_lint:module/2 (erl_lint.erl, line 485)
     in call from erl_bug:test/1 (erl_bug.erl, line 12)
{code}
@OTP-Maintainer
Copy link
Author

hasse said:

Thanks for the bug report. Fixed in commit cfb668 (18.3).

@OTP-Maintainer OTP-Maintainer added bug Issue is reported as a bug team:VM Assigned to OTP team VM priority:low labels Feb 10, 2021
@OTP-Maintainer OTP-Maintainer added this to the OTP-18.3 milestone Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug priority:low team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

2 participants