summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@dashbit.co>2023-01-14 16:00:07 +0100
committerJosé Valim <jose.valim@dashbit.co>2023-01-14 16:00:45 +0100
commitfb4ccfa65699c2da859de37432b6a207c7749fa8 (patch)
treec843b98b593d5e242d20982184cf27c6e42fb21a
parentff2ea697103c9997e215d23e87add800a36522a1 (diff)
downloadelixir-fb4ccfa65699c2da859de37432b6a207c7749fa8.tar.gz
Properly handle Macro inputs and output types in expansion
Closes #12299 Closes #12324
-rw-r--r--lib/elixir/lib/macro.ex6
-rw-r--r--lib/elixir/test/elixir/macro_test.exs2
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/elixir/lib/macro.ex b/lib/elixir/lib/macro.ex
index 5f6633313..1508b2b54 100644
--- a/lib/elixir/lib/macro.ex
+++ b/lib/elixir/lib/macro.ex
@@ -1763,7 +1763,7 @@ defmodule Macro do
end
"""
- @spec expand_once(t(), Macro.Env.t()) :: t()
+ @spec expand_once(input(), Macro.Env.t()) :: output()
def expand_once(ast, env) do
elem(do_expand_once(ast, env), 0)
end
@@ -2000,7 +2000,7 @@ defmodule Macro do
when they change.
"""
@doc since: "1.14.1"
- @spec expand_literals(t(), Macro.Env.t()) :: t()
+ @spec expand_literals(input(), Macro.Env.t()) :: output()
def expand_literals(ast, env) do
{ast, :ok} = expand_literals(ast, :ok, fn node, :ok -> {expand(node, env), :ok} end)
ast
@@ -2080,7 +2080,7 @@ defmodule Macro do
This function uses `expand_once/2` under the hood. Check
it out for more information and examples.
"""
- @spec expand(t(), Macro.Env.t()) :: t()
+ @spec expand(input(), Macro.Env.t()) :: output()
def expand(ast, env) do
expand_until({ast, true}, env)
end
diff --git a/lib/elixir/test/elixir/macro_test.exs b/lib/elixir/test/elixir/macro_test.exs
index f161e5618..6329cae67 100644
--- a/lib/elixir/test/elixir/macro_test.exs
+++ b/lib/elixir/test/elixir/macro_test.exs
@@ -172,7 +172,7 @@ defmodule MacroTest do
end
test "env" do
- env = %{__ENV__ | line: 0}
+ env = %{__ENV__ | line: 0, lexical_tracker: self()}
expanded = Macro.expand_once(quote(do: __ENV__), env)
assert Macro.validate(expanded) == :ok