dialyxir
dialyxir copied to clipboard
Dializer failed pattern match in 'case' clause in 'with' clause
Precheck
- Take a look at the open issues and be sure that your issue is not already covered.
- Be sure your versions of Dialyxir and Erlex are up to date.
Environment
-
Elixir & Erlang/OTP versions (elixir --version): 1.13.4
-
Which version of Dialyxir are you using? (cat mix.lock | grep dialyxir): 1.2.0
Current behavior
- Describe current behavior. Include errors, stack traces, and any additional information that might be important here.
dializer succeeds in Foo.test_1/0
But Foo.test_2/0
failed
defmodule Foo do
def test_1() do
with {:ok, _} <- aa(),
{:ok, _} <- bb(),
{:ok, _} <- cc() do
:success
else
nil -> :error_c
{:error, _} -> :error_a
{:error, _, _} -> :error_b
end
end
def test_2() do
with {:ok, _} <- aa(),
{:ok, _} <- bb(),
{:ok, _} <- cc() do
:success
else
nil ->
:error_c
err ->
case err do
{:error, _} -> :error_a
{:error, _, _} -> :error_b
end
end
end
defp aa() do
if Enum.random(0..1) == 1 do
{:ok, 1}
else
{:error, 2}
end
end
defp bb() do
if Enum.random(0..1) == 1 do
{:ok, 3}
else
{:error, 4, 5}
end
end
defp cc() do
if Enum.random(0..1) == 1 do
{:ok, 6}
else
nil
end
end
end
Expected behavior
- A short description of the expected behavior.
Everyone needs to succeed.
all functions(test_1
, test_2
) work successfully.