elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications

Home Page:https://elixir-lang.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`quote/2` breaks compilation when both `:bind_quoted` and `:context` are given

am-kantox opened this issue · comments

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.17.0-dev (f23434e) (compiled with Erlang/OTP 27)

Operating system

Linux 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Current behavior

The module below

defmodule VersionMeta do
  defmacro failing(some_var) do
    quote bind_quoted: [some_var: some_var], context: __CALLER__.context do
      some_var
    end
  end
end

fails to compile with the following error message

** (MatchError) no match of right hand side value: false
    (elixir 1.17.0-dev) src/elixir_erl_var.erl:16: :elixir_erl_var.translate/4
    (stdlib 6.0) lists.erl:2343: :lists.mapfoldl_1/3
    (stdlib 6.0) lists.erl:2344: :lists.mapfoldl_1/3
    (elixir 1.17.0-dev) src/elixir_erl_pass.erl:42: :elixir_erl_pass.translate/3
    (elixir 1.17.0-dev) src/elixir_erl_pass.erl:315: :elixir_erl_pass.translate_list/4
    (stdlib 6.0) lists.erl:2343: :lists.mapfoldl_1/3
    (stdlib 6.0) lists.erl:2344: :lists.mapfoldl_1/3

If either of bind_quoted and/or context is not presented, there is no issue.

Expected behavior

It should compile.

Related forum thread

https://elixirforum.com/t/compilation-fails-on-1-17-0-dev-because-of-lack-of-version-meta-key/63732/3

As mentioned in the forum thread, this is the commit which introduced it: 37d36f8