ElixirLS Dialyzer: The pattern can never match the type

I am confused.
I have a function with a spec

@spec send(Schema.DocumentStore.t()) :: {:ok, any()} | {:error, any()}
def send(document) do
  with {:ok, .....} do
    {:ok, response}
  else
    {:error, msg} -> {:error, msg]
  end
end

I am calling this function as

case send(document) do
  {:ok, response} ->
     do something
  {:error, msg} ->
     log error
end

I get the warning

ElixirLS Dialyzer: The pattern can never match the type.

Pattern:
{:ok, _response}

Type:
{:error, <<_::112>>}

And I don’t get why.

I think I found it. The function that is being called has another function where I run into an issue because it can raise an error and I cannot get dialyzer to understand the rescue clause.
This percolates the issue, I added a @dialyzer {:no_match, send: 1}, but then the issue pops up in the function that calls this one.

As I thought, getting rid of Multipart.file_field/3, also rids me of the warning.

1 Like