3

I started using Dialyzer (dialyxir 1.0.0-rc.6) on my umbrella project based on Phoenix 1.4.

When I ran mix dialyzer on it for the first time, I got this warning.

apps/my_app/lib/my_app_web/gettext.ex:1:pattern_match_cov
The pattern
%{}

can never match since previous clauses completely cover the type
%{:count => _, _ => _}

Here is the content of this file (gettext.ex):

defmodule MyProject.MyAppWeb.Gettext do
  @moduledoc """
  (*snip*)
  """
  use Gettext, otp_app: :my_app
end

I did not touch it. How can I fix it or suppress warnings?

[UPDATE]

I found this issue closed on 20 Feb 2018:

https://github.com/elixir-lang/gettext/issues/115

I confirmed that newly created phoenix app does not produce dialyzer warnings. I also confirmed with another (freshly created) phoenix umbrella project.

I have not found any solution for my existing project.

[UPDATE 2]

I found how to reproduce my problem.

The newly created application will not warn you, but it will warn you if it contains translation data that actually needs interpolation.

See my github issue comment for more information:

https://github.com/elixir-lang/gettext/issues/115#issuecomment-491591307

Tsutomu
  • 4,848
  • 1
  • 46
  • 68
  • I found a similar bug, also in Gettext. The maintainers mentioned that they don't use Dialyzer. I imagine similar issues are somewhat common for other projects that might be common dependencies for a lot of projects. – Kenny Evitt Nov 15 '19 at 06:29
  • You added your comment after the issue was already closed. The closure note says that if you reproduce the problem to open a new issue. I think you should open a new issue with your description of how to reproduce it. Have you tried running dialyzer directly against gettext to help isolate the issue? – Sinc Jul 05 '21 at 14:07

1 Answers1

2

As a workaround until the bug is fixed, I made .dialyzer_ignores.exs with the following contents in the root directory of umbrella project.

[
  {"apps/app1/lib/app1_web/gettext.ex", :pattern_match_cov},
  {"apps/app2/lib/app2_web/gettext.ex", :pattern_match_cov},
  {"apps/app3/lib/app3_web/gettext.ex", :pattern_match_cov}
]

Here, app1, app2 and app3 are the application names under the umbrella project.

Tsutomu
  • 4,848
  • 1
  • 46
  • 68