[erlang-questions] Dialyzer OTP 19.2 warning for tuple call syntax

Raghav Karol raghav.karol@REDACTED
Mon Mar 6 11:46:57 CET 2017


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?

[1] http://erlang.org/pipermail/erlang-bugs/2015-May/004986.html

-- 
Raghav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170306/9ffb06d0/attachment.htm>


More information about the erlang-questions mailing list