defmodule MapTest.MixProject do
use Mix.Project
def project do
[
app: :map_test,
version: "0.1.0",
elixir: "~> 1.11",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:dialyxir, "~> 1.0", only: [:dev], runtime: false}
]
end
end
map_test.exs
defmodule MapTest do
@moduledoc """
Documentation for `MapTest`.
"""
@spec hello(Map.t()) :: Map.t()
def hello(value) do
value
end
end
dialyzer results
~$ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
New:
dialyxir 1.0.0
erlex 0.2.6
* Getting dialyxir (Hex package)
* Getting erlex (Hex package)
my_name@win10:~/code/map_test$ mix compile
my_name@win10:~/code/map_test$ mix dialyzer
Finding suitable PLTs
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
Looking up modules in dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
Looking up modules in dialyxir_erlang-23.1.5_elixir-1.11.2.plt
Finding applications for dialyxir_erlang-23.1.5_elixir-1.11.2.plt
Finding modules for dialyxir_erlang-23.1.5_elixir-1.11.2.plt
Removing 5 modules from dialyxir_erlang-23.1.5_elixir-1.11.2.plt
Checking 438 modules in dialyxir_erlang-23.1.5_elixir-1.11.2.plt
Adding 5 modules to dialyxir_erlang-23.1.5_elixir-1.11.2.plt
done in 0m23.09s
Finding applications for dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
Finding modules for dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
Copying dialyxir_erlang-23.1.5_elixir-1.11.2.plt to dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
Looking up modules in dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
Checking 443 modules in dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
Adding 67 modules to dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt
done in 2m23.14s
No :ignore_warnings opt specified in mix.exs and default does not exist.
Starting Dialyzer
[
check_plt: false,
init_plt: '/home/my_name/code/map_test/_build/dev/dialyxir_erlang-23.1.5_elixir-1.11.2_deps-dev.plt',
files: ['/home/my_name/code/map_test/_build/dev/lib/map_test/ebin/Elixir.MapTest.beam'],
warnings: [:unknown]
]
Total errors: 1, Skipped: 0, Unnecessary Skips: 0
done in 0m0.79s
:0:unknown_type
Unknown type: Map.t/0.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2
I would rather say that it has some rough edges, like sometimes not super obviousluly clear error messages, and not everyone wants to invest in using it because of that. So be prepared for issues like that or errors showing in your correct code because library has wrong type specs etc.
I don’t think it’s that bad… I don’t know any unfortunately, I think I learned to cope with the existing ones. I think the issue isn’t necessarily in the phrasing of the errors, but more often in determining where the root of the issue is. Which is related, but not the same. For example, I often see issues that a function supposedly “has no return”, but it works just fine, and there are no dialyzer issues reported in its body. I sometimes have to dig deeper into each function called there and hopefully see a reported dialyzer “will never match” or other issue that causes the propagation of “no return” errors.