[erlang-patches] Improve Dialyzer scan error messages

Magnus Henoch <>
Tue Mar 26 15:23:56 CET 2013


Kostis Sagonas <> writes:

> Some comments:
>
> A more convincing example, perhaps with more than one "failing" file,
> would help (me at least) appreciate the great improvement that this
> patch provides.  Also, one should check how this change affects the
> Erlang interface of dialyzer (that of dialyzer:run).  Finally, I am
> not sure I like the extra new line, but that's perhaps a minor point.

You are right about the newline - it shouldn't be there.  I've updated the
patch.

A recent checkout of basho_bench can serve as an example:

git clone git://github.com/basho/basho_bench.git
cd basho_bench/src
git checkout 1276ee6d368a266617d5c22db71f0561d4f46d24
dialyzer --src *.erl

The basho_bench code uses header files from its dependencies, so running
dialyzer without getting the dependencies will fail.  Without the patch,
this is the output:

dialyzer: Analysis failed with error:
Could not scan the following file(s): [{"/private/tmp/basho_bench/src/uuid.erl",
                                        ["/private/tmp/basho_bench/src/uuid.erl:33: bad import declaration\n"]},
                                       {"/private/tmp/basho_bench/src/basho_bench_driver_cassandra_cql.erl",
                                        ["/private/tmp/basho_bench/src/basho_bench_driver_cassandra_cql.erl:28: can't find include lib \"erlcassa/include/erlcassa.hrl\"\n"]},
                                       {"/private/tmp/basho_bench/src/basho_bench_driver_cassandra.erl",
                                        ["/private/tmp/basho_bench/src/basho_bench_driver_cassandra.erl:28: can't find include lib \"casbench/include/cassandra_thrift.hrl\"\n",
                                         "/private/tmp/basho_bench/src/basho_bench_driver_cassandra.erl:54: record columnPath undefined\n"]}]
Last messages in the log cache:
  Reading files and computing callgraph... 

With the patch, the output is:

dialyzer: Analysis failed with error:
Could not scan the following file(s):
/private/tmp/basho_bench/src/uuid.erl:33: bad import declaration
/private/tmp/basho_bench/src/basho_bench_driver_cassandra_cql.erl:28: can't find include lib "erlcassa/include/erlcassa.hrl"
/private/tmp/basho_bench/src/basho_bench_driver_cassandra.erl:28: can't find include lib "casbench/include/cassandra_thrift.hrl"
/private/tmp/basho_bench/src/basho_bench_driver_cassandra.erl:54: record columnPath undefined

Last messages in the log cache:
  Reading files and computing callgraph... 

The former output has lines wider than my screen, while the latter
doesn't, so readability is increased.

The behaviour when using dialyzer:run is mostly unchanged: in both
cases, it throws {dialyzer_error, iolist()} with an iolist starting with
"Analysis failed with error:\nCould not scan the following file(s):".
Subsequent output is changed, but the format of this exception is not
documented, so I hope nothing is relying on that.

Regards,
Magnus


More information about the erlang-patches mailing list