The 'else' clause in 'with' does not support guards

60 views
Skip to first unread message

Alexei Sholik

unread,
Jul 7, 2016, 9:30:33 AM7/7/16
to elixir-lang-core
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.

José Valim

unread,
Jul 7, 2016, 9:32:02 AM7/7/16
to elixir-l...@googlegroups.com
Accidental omission. Please open up an issue. :)



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAAPY6eMv0%2BZ1_jiJmjTBC2-zn3n7SZ13%2BYnM9-WhyARFLA44Ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Alexei Sholik

unread,
Jul 7, 2016, 9:41:28 AM7/7/16
to elixir-lang-core
Reply all
Reply to author
Forward
0 new messages