Dialyzer cannot recognize types from dependencies

Background

I have an umbrella app where I use a dependecy called ETS. This dependency has a type called set_options that I use in some of my specs.

Problem

The code works fine, but dialyzer is complaining. Namely:

lib/web_interface/persistence.ex:11:20:unknown_type
Unknown type: ETS.set_options/0.
________________________________________________________________________________
lib/web_interface/persistence.ex:11:65:unknown_type
Unknown type: ETS.t/0.

Which then cause a ton of cascading errors.

To try and fix this, I added the following to my root mix.exs file (the one from the umbrella app, not the one from the child app):

  def project,
    do: [
      apps_path: "apps",
      version: "2.1.7",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      dialyzer: [
        plt_add_deps: :app_direct,
        plt_add_apps: [
          :ets
        ],
        plt_core_path: "plts",
        plt_local_path: "plts"
      ]
    ]

And then run:

  • mix dialyzer --plt
  • mix dialyzer

This did not work and the output was the same.

I then tried adding this to the mix.exs of the child app in question (alongside the previous changes):

  def application do
    [
      mod: {WebInterface.Application, []},
      extra_applications: [:logger, :ets]
    ]
  end

Unfortunately, nothing worked and I still get the same dialyzer errors.

Question

How can I fix dialyzer so it recognized types from my dependencies?

Both of these appear to be defined in ETS.KeyValueSet rather than the top-level ETS module:

3 Likes