whitfin / cachex

A powerful caching library for Elixir with support for transactions, fallbacks and expirations
https://hexdocs.pm/cachex/
MIT License
1.54k stars 97 forks source link

dialyxir error in cachex/hook.ex:171:pattern_match_cov #351

Closed paulsabou closed 2 months ago

paulsabou commented 2 months ago

I get an unexpected dyalizer error with cachex when I use the hook feature. Am I doing something wrong or I just discovered a minor dyalyzer issue in cachex?

I use cachex 3.6 & elixir 1.17

      {:cachex, "~> 3.6"},
      elixir: "~> 1.17.1",
      {:dialyxir, "~> 1.4", runtime: false},

When using a cachex hook I get the following dialyzer error:

/home/runner-5/runner/_work/..../deps/cachex/lib/cachex/hook.ex:171:pattern_match_cov
The pattern
variable_

can never match, because previous clauses completely cover the type
nil.

My hook is really simple. Looks like this

defmodule Test.MyHook do

  use Cachex.Hook

  @impl true
  def async?(), do: true

end
whitfin commented 2 months ago

Hi! I have no idea, I don't use Dialyzer :)

If you want to look into it and it turns out to be some issue, then feel free to file a fix! My gut feel is that it's because your hook implementation is empty, it's probably not going to happen if you have full logic in there.

paulsabou commented 2 months ago

Thanks for your quick reply @whitfin. I will check it out and if needed will file a fix!