Hi,
the following macro compile if used as in good/2 but if used as in bad/2 elixir fail to compile with the error :ambiguous_catch_try_state (see the full error at the end).
Where does the ambiguity is coming from ?
defmodule TestMacro do
defmacro macro(value) do
quote do
try do
raise ArgumentError, message: "#{inspect unquote(value)}"
rescue
ArgumentError -> :error
end
end
end
end
defmodule Test do
import TestMacro
def good(a, b) do
a = TestMacro.macro(a)
b = TestMacro.macro(b)
{a, b}
end
def bad(a, b) do
{TestMacro.macro(a), TestMacro.macro(b)}
end
end
== Compilation error on file test.ex ==
** (FunctionClauseError) no function clause matching in :elixir_errors.handle_file_error/2
(elixir) src/elixir_errors.erl:170:
:elixir_errors.handle_file_error("Elixir.Test", {:beam_validator,
{{Test, :bad, 2}, {{:bs_append, {:f, 0}, {:integer, 0}, 0, 1, 8, {:x,
0}, {:field_flags, []}, {:x, 1}}, 54, :ambiguous_catch_try_state}}})
(stdlib) lists.erl:1336: :lists.foreach/2
(stdlib) lists.erl:1336: :lists.foreach/2
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
** (exit) shutdown: 1
(elixir) lib/kernel/parallel_compiler.ex:199: Kernel.ParallelCompiler.handle_failure/5
(elixir) lib/kernel/parallel_compiler.ex:182: Kernel.ParallelCompiler.wait_for_messages/8
(elixir) lib/kernel/parallel_compiler.ex:55: Kernel.ParallelCompiler.spawn_compilers/3
(iex) lib/iex/helpers.ex:94: IEx.Helpers.c/2