You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing a three elements tuple where the first element is :quote, the second is anything but a list, and the third is a list with exactly one or two element causes Macro.escape/2 to crash : minimal reproducible example :
iex(1)>Macro.escape({:quote,:foo,[:bar]})**(FunctionClauseError) no function clause matching in:lists.keydelete3/3Thefollowingargumentsweregivento:lists.keydelete3/3:
# 1:column# 21# 3:foo(stdlib5.2.1) lists.erl:885: :lists.keydelete3/3(elixir1.16.2) src/elixir_quote.erl:561: :elixir_quote.meta/2(elixir1.16.2) src/elixir_quote.erl:294: :elixir_quote.do_quote/3iex:1: (file)
iex(1)>Macro.escape({:quote,:foo,[:bar,:baz]})**(FunctionClauseError) no function clause matching in:lists.keydelete3/3Thefollowingargumentsweregivento:lists.keydelete3/3:
# 1:column# 21# 3:foo(stdlib5.2.1) lists.erl:885: :lists.keydelete3/3(elixir1.16.2) src/elixir_quote.erl:561: :elixir_quote.meta/2(elixir1.16.2) src/elixir_quote.erl:294: :elixir_quote.do_quote/3iex:1: (file)
A fix is easy enough and I'll submit a PR shortly. However, I'm not entirely convinced that it is possible to completely fix the issue, as tuples of this form may be ambiguous when using Macro.escape/2. For example we have :
Attempts to solve an issue that causes `Macro.escape/2` to crash when
given certain tuples.
Note that, `Macro.escape({:quote, [column: 10], [:foo]})` still produces
: `{:{}, [], [:quote, [], [:foo]]}` which is arguably wrong.
Elixir and Erlang/OTP versions
elixir version 1.16. and up, any otp version.
Operating system
any
Current behavior
Passing a three elements tuple where the first element is
:quote
, the second is anything but a list, and the third is a list with exactly one or two element causesMacro.escape/2
to crash : minimal reproducible example :This issue was first reported in absinthe : #absinthe-graphql/absinthe/issues/1313
Expected behavior
The function should properly escape the tuple :
A fix is easy enough and I'll submit a PR shortly. However, I'm not entirely convinced that it is possible to completely fix the issue, as tuples of this form may be ambiguous when using Macro.escape/2. For example we have :
Which is surprising and arguably a bug as well, and is not solved by the solution I'll submit.
The issue here is that those are caught by the clauses on line 266 of the
src/elixir_quote.erl
, namely :I have attempted but failed to solve the issue at this point, it's unclear to me what careful pattern matching could solve the issue, if any.
The text was updated successfully, but these errors were encountered: