Dialyzer missing message in OTP 24

Hello Everyone,

In my company after upgrading our projects to OTP 24 we encountered some unhelpful and incomplete error messages from dialyzer during development.

The error message was:

Warning: Function hello/0 has no local return.

And nothing more. Then after some investigation we found out that inside this function there was a spec violation when calling another function but dialyzer didn’t tell us anything about that.

We got curious and reproduced the same error with OTP 23 and realized this time we’ve got a full explanation from dialyzer:

Warning: Function hello/0 has no local return.
________________________________________________________________________________
lib/test_dialyzer.ex:16:call
Warning: The function call will not succeed.

System.system_time(:seconds)

breaks the contract
(time_unit()) :: integer()

It seems like something is broken in OTP 24 dialyzer.

Am I doing something wrong or should we file this issue in erlang issue tracker?

You can also see the tests reproduced in this repo: github.com/alisinabh/test_dialyzer

1 Like

edit: I now understand that the :seconds issue is on purpose to demonstrate the missing more helpful error?

(Time unit (since a few Elixir/Erlang versions) is :second, not :seconds (spec). :seconds is probably still working for compatibility reasons)

This looks similar to this elixir issue. Elixir doesn’t return proper location in many of returned Erlang AST forms and since Erlang 24 this may cause Dialyzer to not show some of the warnings. Location was added to some forms as part of resolving that issue but many generated forms have still location default to 0 and that may be happening here as well.

Yes indeed that is intentional.

Thanks for the info. This seems related.

I’ve tried the current master branch of elixir (commit 90bfc1f0) but the error is still the same! It seems this fix by @josevalim was not enough or is not related to this issue.

I think it’s related, it’s just a different scenario of the same issue (literals missing location) that was not covered by the fix. elixir_erl_pass:translate_args/3 was added but /2 is still exported and doesn’t take and pass down the location. Or the zero location for the :seconds atom gets in there a different way.

I’ve sent a PR to Elixir that should restore this warning: Pass annotation to arguments in more scenarios by michallepicki · Pull Request #11217 · elixir-lang/elixir · Gi

3 Likes

Thank you @michallepicki
I’ve tested it on the issue and it is indeed fixed.

Wish you all the best :green_heart:

3 Likes

Happy dialyzing! Feel free to reach out when you notice other similar issues, maybe I’ll be able to help.

2 Likes