Dialyxir: unknown_type for some :crypto types

Hi all,

When running Dialyxir I’ve got the following warnings:

:0:unknown_type
Unknown type: :crypto.ec_named_curve/0.
________________________________________________________________________________
:0:unknown_type
Unknown type: :crypto.sha1/0.
________________________________________________________________________________
:0:unknown_type
Unknown type: :crypto.sha2/0.
________________________________________________________________________________

It seems to me that these types do exist nonetheless:
http://erlang.org/doc/man/crypto.html#type-ec_named_curve
http://erlang.org/doc/man/crypto.html#Digests

and Dialyxir does include :crypto:

[2630:2592 - 0:2034] 10:37:01 [me@soulwax:o +1] ~/coding/wax 
$ mix dialyzer
Finding suitable PLTs
Checking PLT...
[:asn1, :cbor, :certifi, :compiler, :crypto, :elixir, :hackney, :httpoison, :idna, :jason, :kernel, :logger, :metrics, :mimerl, :public_key, :ssl, :ssl_verify_fun, :stdlib, :unicode_util_compat, :x509]
PLT is up to date!
Starting Dialyzer
[
  check_plt: false,
  init_plt: '/home/me/coding/wax/_build/dev/dialyxir_erlang-21.0_elixir-1.7.2_deps-dev.plt',
  files_rec: ['/home/me/coding/wax/_build/dev/lib/wax/ebin'],
  warnings: [:unknown]
]

Here are the specs:

@spec to_erlang_curve(non_neg_integer()) :: :crypto.ec_named_curve()

@spec to_erlang_digest(t()) :: :crypto.sha1() | :crypto.sha2()

Any idea why Dialyxir cannot find them?

Have a good day!

1 Like

Seems those types were added somewhat recently. Make sure your OTP version is up to date for those changes. Looks like you’re on 21.0, but make sure you’re on at least 21.0.7 as it seems that timeline coincides with that PR.

As an aside, I really wish Dialyzer gave me more information on those errors so I could at least tell you where they come from in your code. The :0 is just not helpful.

https://github.com/erlang/otp/commit/35848c8ba5968b0d9aec3f7aaac6d31000e4da15#diff-1315c36aca592e79ef0073fcf3019e5f

https://github.com/erlang/otp/commit/f7012b7a731924193cf05fc77b103e89bd0fcbfb#diff-a145c6debe9783c95d482921df5d1fbb

3 Likes

That’s it, thanks! My OTP version is 21.0:

$ erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell
21.0

Agree, the :0 thing is not very conveninet, had to grep -nrw to find the locations of the unknowns types.