Dialyzer version 2.9. Erts 7.3. OTP 18.
In the following contrived erlang code:
-module(dialBug).
-export([test/0]).
%-export([f1/1]). % uncomment this line
test() ->
f1(1).
f1(X) when X > 5 ->
X*2.
When dialyzer is run over the above code it warns that the code won't work as the guard test (X > 5) can never succeed.
However, when I uncomment the 3rd line and export the f1/1 function dialyzer no longer issues any warnings.
I realise that when f1/1 is exported it is impossible for dialyzer to know that the guard clause will fail as external clients can use it. However, why can it no longer determine that test/0 is using f1/1 incorrectly?