jeremyjh/dialyxir

Ignore_warnings file not ignoring warnings after upgrade to OTP 24

Open

#448 opened on Nov 23, 2021

 (6 comments) (4 reactions) (0 assignees)Elixir (160 forks)batch import
help wanted

Repository metrics

Stars
 (1,794 stars)
PR merge metrics
 (Avg merge 122d 13h) (1 merged PR in 30d)

Description

Precheck

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 24 [erts-12.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.12.3 (compiled with Erlang/OTP 24)
  • Which version of Dialyxir are you using? (cat mix.lock | grep dialyxir):
 "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},

Current behavior

TLDR: Warnings are emitted even after placing filters in the ignore file.

While working in another big project, we silenced an Dialyzer warning (due to the use of money ecto type) through the use of the ignore_warnings file.

After updating to OTP 24, the warnings showed up again when running mix dialyzer, this is preventing us from updating to OTP 24, since it's failing at our CI.

This repo attempts to provide a reproducible example of the warning through a wrong spec, although it's not the only warning we're getting (and in a different scenario).

Dialyzer output:

❯ mix dialyzer
Finding suitable PLTs
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :money, :stdlib]
PLT is up to date!
ignore_warnings: .dialyzer_ignore.exs

Starting Dialyzer
[
  check_plt: false,
  init_plt: '.../dialyxir_test/_build/dev/dialyxir_erlang-24.0.2_elixir-1.12.3_deps-dev.plt',
  files: [...],
  warnings: [:unknown]
]
Total errors: 1, Skipped: 0, Unnecessary Skips: 1
done in 0m1.19s
lib/dialyxir_test.ex:19:unknown_type
Unknown type: Money.Ecto.Composite.Type.t/0.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

ignore file (we use line 19 for this example, but the actual error is on line 0):

# This file should be empty ALWAYS. Use it only for emergencies.
[
  {":19:unknown_type Unknown type: Money.Ecto.Composite.Type.t/0."},
]

mix file:

defmodule DialyxirTest.MixProject do
  use Mix.Project

  def project do
    [
      app: :dialyxir_test,
      version: "0.1.0",
      elixir: "~> 1.12",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      dialyzer: [
        ignore_warnings: ".dialyzer_ignore.exs",
      ]
    ]
  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
    [
      {:money, "~> 1.9.0"},
      {:dialyxir, "~> 1.0", only: [:dev], runtime: false},
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
    ]
  end
end

Expected behavior

It should ignore the warnings specified in the ignore file.

Contributor guide