From fb4ccfa65699c2da859de37432b6a207c7749fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 14 Jan 2023 16:00:07 +0100 Subject: Properly handle Macro inputs and output types in expansion Closes #12299 Closes #12324 --- lib/elixir/lib/macro.ex | 6 +++--- lib/elixir/test/elixir/macro_test.exs | 2 +- 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 -- cgit v1.2.1