Dialyzer and exported types

I recently made a project with cowboy as a dependency and I used cowboy_req:req/0 type in my own specs. When I run dialyzer on the project I get the following errors:

_build/default/lib/cowboy/src/cowboy_req.erl
Line 134 Column 9: Unknown type ranch:ref/0
Line 152 Column 18: Unknown type ranch_proxy_header:proxy_info/0

Both types exist and are exported from ranch module.

Problem disappears when I add ranch in my .app file, but shouldn’t dialyzer handle that as ranch is the dependency of cowboy? Is that expected behavior or is it a bug?

I’m using cowboy 2.12.0 and rebar3 3.23.0 on OTP 27.0.0

1 Like

I have also noticed this. It started in Erlang 26 iirc.

What changed in OTP 26 is that unknown types are mentioned every time by dialyzer. By default rebar3 only analyzes top-level apps and top-level deps.

To analyze the whole project, configure dialyzer with:

{dialyzer, [
    {plt_apps, all_deps},
    …
]}.

You can also see at Base Config | Rebar3 that you can specify only particular apps to add with the extra option. You can also turn off the OTP 26 behavior by passing in the no_unknown warning option.

3 Likes