tino415

tino415

Dialyzer cachex unable to solve types

Hello all,

I’m triing to integrate dialyzer/dialyxer into one project that is using cachex, but dialyzer keeps reporting some veird error with Cachex.start_link/2 function. I managed to destille minimal example:

defmodule Test do
  def hello do
    {:ok, _pid} = Cachex.start_link(__MODULE__, stats: true)
  end
end

Dialyzer is complaining that

lib/test.ex:3:pattern_match
The pattern can never match the type.

Pattern:
{:ok, __pid}

Type:
:error | :ok | {:error, atom() | {:already_started, pid() | {_, _}}}

But when I tri to run function in iex, it returns {:ok, pid()}, also when I look at the code, typescpecs seems right and code also, so, how did dialyzer come up with return type :error | :ok | {:error, atom() | {:already_started, pid() | {_, _}}}? The code for Cachex.start_link/2 looks like this:

  @spec start_link(atom | Keyword.t) :: { atom, pid }
  def start_link(options) when is_list(options) do
    with { :ok,  name } <- Keyword.fetch(options, :name),
         { :ok,  true } <- ensure_started(),
         { :ok,  true } <- ensure_unused(name),
         { :ok, cache } <- setup_env(name, options),
         { :ok,   pid }  = Supervisor.start_link(__MODULE__, cache, [ name: name ]),
         { :ok,  link }  = Informant.link(cache),
                ^link   <- Overseer.update(name, link),
     do: { :ok,   pid }
  end
  def start_link(name) when not is_atom(name),
   do: error(:invalid_name)
  def start_link(name),
    do: start_link(name: name)

  @doc false
  @spec start_link(atom(), Keyword.t) :: { atom(), pid() }
  def start_link(name, options),
    do: start_link([name: name] ++ options)

Anybody have experience with similar problem and how to solve it?

Marked As Solved

michallepicki

michallepicki

This seems to be a bug in specs in the sleeplocks library and should be fixed by https://github.com/whitfin/sleeplocks/pull/5

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement