Dialyzer and 'with' error


I have several dialyzer errors following the pattern below:

The pattern {'ok', _@3} can never match the type {'error',{'error','invalid_key' | 'no_ring'}}

The code snippet

def show(conn, remote_node_name) do
    with {:ok, remote_node_atom} <- Util.to_existing_atom(remote_node_name),
            {:ok, node_list} <- RiakNode.attrs(),
            all_metrics = get_metrics(node_list) do
                render(conn, "metrics.json", metrics: all_metrics)
      {:error, _} ->
# Util.to_existing_atom is String.to_existing_atom which traps the Exception and converts it into {:error, :invalid_key}
# RiakNode.attrs :: {:ok, list} | {:error, :no_ring} 

The dialyzer error doesn’t make sense since it should be trapped with {:error, _}
I tried expanding the errors into 2 separate clauses but that didn’t work either.

Which version of elixir are you using?

I remember there were bugs with dialyzer and with, but they should be fixed by now.

1 Like

Interactive Elixir (1.4.5)

1.4 is very old, you should update to a more recent version.

Eh, I still get these dialyzer warnings with 1.6.3.

At least I think so… let me check…

EDIT: Hmm, I think I fixed all those I had, or 1.6.3 has them fixed, I just have case things showing warnings because another’s API says it returns things when it actually returns ‘more’ things (I need to send more issues to libraries)…

1 Like