Dialyzer reporting 'Unknown type: Map.t/0.'

It just happened when I run ~$ mix dialyzer.

Total errors: 1, Skipped: 0, Unnecessary Skips: 1
done in 0m1.84s
Unknown type: Map.t/0.


  1. Why there is no file path and class name, really not sure where this problem from?
  2. I thought Map.t() is a primity type, and clearly dialyzer tells me not, whats wrong herer?

If types of the standard library are unknown, then its usually that you misconfigured dialyzer and are missing some PLTs.

I’m also not sure why it doesn’t give you no file name and line number, as I do not have access to your code.

Unknown type warnings do not show file and line numbers at all. This might hopefully be fixed in Erlang 24 thanks to this PR: dialyzer: Add file and location to messages about unknowns by uabboli · Pull Request #3018 · erlang/otp · GitHub

1 Like

Sorry for not showing my code.


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()

  # Run "mix help compile.app" to learn about applications.
  def application do
      extra_applications: [:logger]

  # Run "mix help deps" to learn about dependencies.
  defp deps do
      {:dialyxir, "~> 1.0", only: [:dev], runtime: false}


defmodule MapTest do
  @moduledoc """
  Documentation for `MapTest`.

  @spec hello(Map.t()) :: Map.t()
  def hello(value) do

dialyzer results

~$ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
  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
Unknown type: Map.t/0.
done (warnings were emitted)
Halting VM with exit status 2

I don’t think the Map module has a type t : Map — Elixir v1.11.3

Use map() or better yet, %{} with specifying the fields as well: Typespecs — Elixir v1.11.3

Thanks it works!!!

is it dialyzer still in-complete after years of development?

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’m having a tough time using libraries(even google) that having wrong type spec. That really makes me frustrated.

1 Like

Sometimes I fork a library and submit a patch, or just remove all their type specs to fix those issues propagating to my code :man_shrugging:

Maybe @dazuma will consider removing all the type specs from google libraries and adding comments instead?

yes, some libraries did lack of updates

is it other type checking system would be better? e.g. norm, type check, etc

I have no experience with either of them.

Hi Michal.
Do you know of any library that translate Dialyzer errors into human readable ones? Other than what Dialyxir does

1 Like

human readable ones

I don’t think it’s that bad… :smiley: 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.

1 Like

Well, they could definitely be better. I think the lack of alternatives makes us feel accustomed to it. :joy:

1 Like