[erlang-questions] Dialyzer and erlsom

Kostis Sagonas kostis@REDACTED
Tue Sep 8 13:30:11 CEST 2015


On 09/08/2015 12:33 PM, Alexander Petrovsky wrote:
> Hi!
>
> I've built PLTs with the follow commands via Makefile:
>
> DIALYZER_APPS = asn1 compiler crypto erts inets kernel public_key sasl
> ssl stdlib syntax_tools tools
>
> ...
>
> dialyzer --build_plt --output_plt erlang.plt --apps $(DIALYZER_APPS)
> dialyzer --build_plt --output_plt my_app.plt ebin/ deps/*/ebin/
>
> then I want to check my code with dialyzer but got the follow errors:
>
> $ make dialyzer
> dialyzer --src src --plts erlang.plt my_app.plt -Wunmatched_returns
> -Werror_handling -Wrace_conditions -Wunderspecs | fgrep -v -f
> ./dialyzer.ignore-warnings
>    Checking whether the PLT erlang.plt is up-to-date... yes
>    Checking whether the PLT my_app.plt is up-to-date... yes
>    Proceeding with analysis...
> dialyzer: Analysis failed with error:
> ... <SNIP>
>
> In my_app_parser I have:
>
> -include_lib("erlsom/src/erlsom_sax.hrl").
>
> How to say dialyzer to find erlsom_sax.hrl in deps/erlsom/src/ ? How can
> I fix it?

Stavros has already replied to your question (alas in a top-post :-( ) 
mentioning the -I option that dialyzer accepts and the fact that you'll 
be better off analyzing .beam files instead of .erl ones.

I wanted to point out something else, slightly unrelated to your 
question, because it's a common error I see in the use of dialyzer.

You start by building an erlang.plt file for all Erlang/OTP apps you are 
using.  That's great.  But then you are building a PLT not only for the 
dependencies of your application, which is fine, but also for the files 
(those under ebin/) that you want to then analyze.  Why do you do that? 
  There is no real harm in doing so, but this means that if you 
subsequently modify any of the files under your src/ and re-compile, the 
information in the cached my_app.plt file will need to be rebuilt.

The idea of PLT files is that you cache there type information of files 
that are considered as the "trusted base" of dialyzer's analysis, which 
consists of files that rarely change (like those in the Erlang/OTP 
system you employ).

So, I would argue against building/including in the PLT any information 
about the files of the application you want to dialyze.

Kostis



More information about the erlang-questions mailing list