Closed
Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.2.6] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.19.0-rc.0 (2a9a4f2) (compiled with Erlang/OTP 27)
Operating system
macOS 14.7.6 (23H626)
Current behavior
When we pass a fn with a fallback clause into then/1
, the type checker is confused :)
defmodule A do
def a() do
case b() do
:ok -> :ok
:error -> :error
end
end
defp b() do
[true, false]
|> Enum.random()
|> then(fn
true -> :ok
_ -> :error
end)
end
end
warning: the following clause will never match:
:ok
because it attempts to match on the result of:
b()
which has type:
dynamic(:error)
typing violation found at:
│
4 │ :ok -> :ok
│ ~~~~~~~~~~
│
└─ a.ex:4: A.a/0
Expected behavior
Shouldn't be a violation
Metadata
Metadata
Assignees
Labels
No labels