@spec something() :: :foo | :bar
def something() do
wait [10] |> Stream.cycle() |> Stream.take(10) do
true_or_false?(true)
after
_ -> :foo
else
_ -> :bar
end
end
@spec true_or_false?(boolean()) :: boolean()
defp true_or_false?(true), do: true
defp true_or_false?(false), do: false
I would receive this dialyzer issue:
lib/something.ex:15:pattern_match
The pattern can never match the type.
Pattern:
_ = nil
Type:
true
________________________________________________________________________________
I tracked it down to the pattern match against false/nil being separate lines. If you have a function returning true or false, you'll never match against nil. Dialyzer doesn't like that.
Using
wait
like this:I would receive this dialyzer issue:
I tracked it down to the pattern match against
false/nil
being separate lines. If you have a function returningtrue
orfalse
, you'll never match againstnil
. Dialyzer doesn't like that.This PR fixes it, from what I can tell.