Dialyxir: unknown_type for some :crypto types

Hi all,

When running Dialyxir I’ve got the following warnings:

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

It seems to me that these types do exist nonetheless:

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.




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

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