[erlang-bugs] Dialyzer can't compile map correctly

Kostis Sagonas kostis@REDACTED
Tue Dec 16 01:46:23 CET 2014


On 12/16/2014 01:07 AM, Jesper Louis Andersen wrote:
> Hi OTP team and other interested parties.
>
> While I was building up the enacl application, I have discovered a
> problem where I can crash the dialyzer.

Dialyzer should of course not crash and should be fixed, but your 
program is crap and dialyzer (rightfully) throws up on such code ;)

It's caused by the following two functions which make the 
crypto_box_keypair/0 function not returning:

not_loaded() ->
     error({nif_not_loaded, ?MODULE}).

crypto_box_keypair() -> not_loaded().


So your use of the call to enacl_nif:crypto_box_keypair() in the enacl 
module makes Dialyzer think that the particular call will not return. 
Thus, the -spec box_keypair() -> #{ atom() => binary() }. that you have 
specified is wrong as far as Dialyzer is concerned.  It crashes when in 
the phase that it tries to generate the warning.  Dialyzer should of 
course be fixed so that its analysis does not crash when generating 
warnings for specs that contain (erroneous) map types, but this will not 
fix the problem(s) in your code base.

Kostis



More information about the erlang-bugs mailing list