Dialyzer is complaining about Elixir types like Atom.t
$ mix dialyzer
Compiling 1 file (.ex)
...
Proceeding with analysis...
Unknown types:
'Elixir.Atom':t/0
done in 0m1.72s
done (passed successfully)
(In a real program, its also complaining about my use of other types, like List.t
, Boolean.t
, etc).
If I replace Atom.t with atom() - then it works.
I noticed also that the source for the Atom module does not include a typespec, as I assume Elixr is substituting Atom.t with atom() automatically, but Dialzer does not know about that. That seems like bad news, and I hope I am wrong, or that there is some easy way to suppress these warnings, because to edit my code and put atom() etc all the way through the specs, seems like the wrong thing to be doing,
Following is the simple test source:
defmodule Test do
@spec test() :: Atom.t
def test() do
:ok
end
end
And the mix.exs:
defmodule Test.Mixfile do
use Mix.Project
def project do
[app: :test,
version: "0.1.0",
elixir: "~> 1.4-rc",
deps: deps()
]
end
def application do
[]
end
defp deps do
[{:dialyxir, "~> 0.4", only: [:dev], runtime: false}]
end
end
Full output:
$ mix dialyzer
Compiling 1 file (.ex)
Generated test app
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
Finding suitable PLTs
Looking up modules in dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Looking up modules in dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1.plt
Finding applications for dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1.plt
Finding modules for dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1.plt
Checking 380 modules in dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1.plt
Finding applications for dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Finding modules for dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Copying dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1.plt to dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Looking up modules in dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Checking 380 modules in dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Adding 57 modules to dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt
Starting Dialyzer
dialyzer --no_check_plt --plt /home/brian/Development/test/test/_build/dev/dialyxir_erlang-19.1.5_elixir-1.4.0-rc.1_deps-dev.plt /home/brian/Development/test/test/_build/dev/lib/test/ebin
Proceeding with analysis...
Unknown types:
'Elixir.Atom':t/0
done in 0m1.72s
done (passed successfully)
Using Dialyxir 0.4.1, Dialyzer 3.0.2 on Ubuntu, with ELixir v1.4 and Erlang
$ uname -a
Linux brian-B85M-HD3-A 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ grep version deps/dialyxir/mix.exs
version: "0.4.1",
$ dialyzer --version
Dialyzer version v3.0.2
$ iex --version
Erlang/OTP 19 [erts-8.1] [source-e7be63d] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
IEx 1.4.0-rc.1 (9c734ac)
$ erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 8.1