Trying to compile the following piece of code
with :ok <- {:error, :foo} do
:ok
else
{:error, reason} when reason in [:foo, :bar] ->
:some_error
{:error, _} ->
:generic_error
end
results in this error
** (CompileError) iex:1: cannot invoke local when/2 inside match, called as: {:error, reason} when :erlang.or(:erlang.=:=(reason, :bar), :erlang.=:=(reason, :foo))
I wonder if there's a specific reason for not supporting everything the 'case' expression supports in the 'else' clause? It looks like an accidental omission to me.