<div dir="ltr"><div>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.</div><div><br></div><div>%% BEGIN INLINE CODE</div><div><div>-module(dialyzer_warning).</div><div><br></div><div>-export([new/0,</div><div> function/1, function/0,</div><div> main/0]).</div><div><br></div><div>-ifdef(TEST).</div><div>-include_lib("eunit/include/eunit.hrl").</div><div>-endif.</div><div><br></div><div>new() -></div><div> {?MODULE, ['this', 'is', 'fun']}.</div><div><br></div><div>function(S = {?MODULE, _Args}) -></div><div> S.</div><div><br></div><div>function() -></div><div> ?MODULE.</div><div><br></div><div>main() -></div><div> M0 = ?MODULE,</div><div> ?MODULE = M0:function(),</div><div><br></div><div> M1 = new(),</div><div> M1 = M1:function().</div><div><br></div><div>-ifdef(TEST).</div><div>module_call_test() -></div><div> M = ?MODULE,</div><div> ?MODULE = M:function().</div><div><br></div><div>tuple_call_test() -></div><div> M = new(),</div><div> M = M:function().</div><div>-endif.</div><div>%% END INLINE CODE</div><div><br></div><div><div><div>Running dialyzer like `(. ~/erlang/19.2/activate && rebar3 dialyzer)`, produces: <br></div><div><br></div><div>src/dialyzer_warning.erl</div><div> 21: Function main/0 has no local return</div><div> 26: The call M1:'function'() requires that M1 is of type atom() not {'dialyzer_bug',['fun' | 'is' | 'this',...]}</div></div></div><div><br></div><div>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?</div><div><br></div><div>[1] <a href="http://erlang.org/pipermail/erlang-bugs/2015-May/004986.html">http://erlang.org/pipermail/erlang-bugs/2015-May/004986.html</a></div><div><br></div>-- <div class="gmail_signature">Raghav</div><div class="gmail_signature"><br></div>
</div></div>