AdRoll / rebar3_hank

The Erlang Dead Code Cleaner
MIT License
68 stars 9 forks source link

NIF check makes hank crash in some scenarios #79

Closed elbrujohalcon closed 3 years ago

elbrujohalcon commented 3 years ago

Bug Description

Since we added the NIF check in #75, some code makes Hank crash.

To Reproduce

Try to analyze this module…

-module(my_mod).

dummy_fn(A) ->
    Fn = fun (B) -> B end,
    Fn(A).

to_json(X) ->
    to_json(X, percentage).

Expected Behavior

No warnings.

rebar3 Logs

===> error analyzing files: {badarg,{var,57,'Fn'}}
Stack: [{erl_syntax,data,1,[{file,"erl_syntax.erl"},{line,8251}]},
        {erl_syntax,module_qualifier_argument,1,
            [{file,"erl_syntax.erl"},{line,3618}]},
        {hank_utils,application_node_to_mfa,1,
            [{file,
                 "/Users/fernandobenavides/Projects/elbrujohalcon/test_hank/_checkouts/rebar3_hank/src/hank_utils.erl"},
             {line,74}]},
        {unnecessary_function_arguments,is_clause_a_nif_stub,1,
            [{file,
                 "/Users/fernandobenavides/Projects/elbrujohalcon/test_hank/_checkouts/rebar3_hank/src/rules/unnecessary_function_arguments.erl"},
             {line,71}]},
        {unnecessary_function_arguments,'-check_function/1-fun-1-',2,
            [{file,
                 "/Users/fernandobenavides/Projects/elbrujohalcon/test_hank/_checkouts/rebar3_hank/src/rules/unnecessary_function_arguments.erl"},
             {line,52}]},
        {lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
        {unnecessary_function_arguments,check_function,1,
            [{file,
                 "/Users/fernandobenavides/Projects/elbrujohalcon/test_hank/_checkouts/rebar3_hank/src/rules/unnecessary_function_arguments.erl"},
             {line,51}]},
        {unnecessary_function_arguments,analyze_function,2,
            [{file,
                 "/Users/fernandobenavides/Projects/elbrujohalcon/test_hank/_checkouts/rebar3_hank/src/rules/unnecessary_function_arguments.erl"},
             {line,37}]}]