Quantcast

Dialyzer OTP 19.2 warning for tuple call syntax

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Dialyzer OTP 19.2 warning for tuple call syntax

Raghav Karol
While trying to run dialyzer on `mochiweb` using OTP 19.2, I observed warnings when a tuple, M = `{?MODULE, Args}` is used to call a function like `M:function()`. The compiler and runtime still allow these calls. Here is a simple module that produces the warning.

%% BEGIN INLINE CODE
-module(dialyzer_warning).

-export([new/0,
         function/1, function/0,
         main/0]).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.

new() ->
    {?MODULE, ['this', 'is', 'fun']}.

function(S = {?MODULE, _Args}) ->
    S.

function() ->
    ?MODULE.

main() ->
    M0 = ?MODULE,
    ?MODULE = M0:function(),

    M1 = new(),
    M1 = M1:function().

-ifdef(TEST).
module_call_test() ->
    M = ?MODULE,
    ?MODULE = M:function().

tuple_call_test() ->
    M = new(),
    M = M:function().
-endif.
%% END INLINE CODE

Running dialyzer like `(. ~/erlang/19.2/activate && rebar3 dialyzer)`, produces: 

src/dialyzer_warning.erl
  21: Function main/0 has no local return
  26: The call M1:'function'() requires that M1 is of type atom() not {'dialyzer_bug',['fun' | 'is' | 'this',...]}

From a previous post [1] I understand this feature, call with module-as-a-tuple should still be supported and I'm wondering how does one handle using OTP 19.2 on an existing codebase like mochiweb that makes use of module-as-a-tuple?


-- 
Raghav


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...