[erlang-questions] Dialyzer failing to find simple type error
Thu Jan 1 23:57:21 CET 2015
You are confusing Dialyzer with a static type checker (which it isn't ).
In one of your examples, there is no problem, and in the other one, the
analysis would have to be pretty strong (and have a different type domain)
to find the problem.
In test.erl, you have the success typings (written as specs)
-spec bar() -> 1 | 0.
-spec foo(1) -> 'ok'
So applying foo(bar()) _can_ succeed, which makes it perfectly fine in
Similarly, in test2.erl you have the success typings
-spec bar(any()) -> 'foo' | 'bar'.
-spec foo('foo') -> 'ok'.
ok = foo(bar(1)),
ok = foo(bar(2)).
once again _can_ succeed (based on the success typings) so Dialyzer remains
Arguably, if Dialyzer's analysis was strong enough to infer the type
-spec bar (1) -> 'foo';
(<Anything but 1>) -> 'bar',
it could warn, but the above typing is way beyond Dialyzer.
2015-01-01 17:24 GMT+01:00 Philip Müller <mail@REDACTED>:
> Hi there,
> a few days ago I wanted to demonstrate the dialyzer to a friend who is
> unfamiliar with erlang/otp.
> Unfortunately, my simplest demo case did not work. I made a github project
> for it at  which documents the steps taken.
> For me, the first case (test.erl) looks like dialyzer is ignoring
> -Wunmatched_returns completely. The second case (test2.erl) I don't
> understand at all.
> Can someone explain what's going on there? Or should I file a bug report?
> Best regards
> : https://github.com/exterm/dialyzer-fail-example
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions