Erlydtl and dialyzer warnings

Would love my dialyzer to run without warnings.

In one project, I have erlydtl rendering beam files, and I am not sure where to park any -dialyzer({nowarn_function, [foo_foo_dtl:render/1, foo_bar_dtl:render/1, foo_baz_dtl:render/1]}). as there is no module source for these ``dynamic’’ templates… an aside, I don’t think dialzyer would allow the list of MFArity anyway, but the above is pseudocode for what I’d like to do, somewhere …

Interwebs yields nothing on this, surprisingly. Anyone know a proper solution to have dialyzer run green with Erlydtl DTLS? Hacks welcome, too!

Dialyzer gives me this:

Unknown functions:
foo_foo_dtl:render/1 …
foo_bar_dtl:render/1 …
foo_baz_dtl:render/1 …

Thanks! Will provide more details if needed.


If you’re building with rebar3, you can set {exclude_mods, [foo_foo_dtl, foo_bar_dtl, foo_baz_dtl]} option in the dialyzer section in rebar.config.
If you are not building with rebar3, than you can set the dialyzer to run on the src_code, rather than the byte_code. If there is no erlang source for the problem-causing modules then no errors should be thrown.
In either way, you exclude the whole modules from analysis, not just render/1.

1 Like

Thanks for the reply. Using POSIX make.

To expand a tad, the offending module is actually foo_lib.erl that calls these dynamic dtl like this:

do_dtl(foo) ->
    fun foo_foo_dtl:render/1;

So dialyzer can’t anticipate the dynamic creation of this byte code (render/1 is some kind of erlydtl magic). So, no. No source code – no *dtl.erl files.


1 Like

Put another way: does anyone know if it’s possible to have dialyzer ignore MFA calls that don’t exist?



bar() ->
    U = fun call_to_something_that_doesnt_exist:foo/1,
    {ok, U}.

This is essentially what I’m trying to get away with Erlydtl and dialzyer. It’s a specific issue given the dynamic nature of the byte-code creation having no source code…


Aha, I think i got it now. So if the error is in the bar/0, then you should use -dialyzer({nowarn_function, [bar/0]}).

I’m not 100% sure because I can’t reproduce the error on my machine. If this is not the solution you wanted please post error message from the dialyzer.

1 Like

I’ll try that and post the results should it work. Talking it out with you has been helpful; thanks!


I couldn’t get the ``Unknown functions:‘’ warning to go away with any -dialyzer(...) module attribute that I could find. Those things do work, just couldn’t get it to stop complaining about code that pointed to an MFA that didn’t (yet) exist (see my foo module above).

1 Like

So, I tried building with rebar3 and OTP25 and directly from CLI with dialyzer v5.0 and the results are different considering unknown functions warnings. From dialyzer manpage, the default behaviour should be that unknown functions do not affect the return status of the dialyzer. So, even if the warnings are printed, return status should be 0.

Also, try specifying “-q” flag when running dialyzer from CLI, that in my case prevented unknown functions warnings from printing.

Rebar3 filters unknown warnings in rebar_prv_dialyzer.erl at line 600, so that works.
If you want to build with make, you can start erlang VM that would call dialyzer:run([Options]), print the resutlts and exit. So the dialyer command would be something like erl -run dialyzer run <dialyzer options> -run init stop -noshell. That is all I can suggest…


So much good stuff here; thanks! I do like this tool so the more I learn about it, the better. Thanks for your time!