Skip to content

Build attributes AST for non-:__block__ container attributes with opts #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/mix/tasks/compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ defmodule Mix.Tasks.Compile.Speck do
{name, [:map], [], Enum.map(attributes_ast, &build_attribute/1)}
end

defp build_attribute({:attribute, _, [[name], opts_ast, [do: attributes_ast]]}) do
{opts, _} = Code.eval_quoted(opts_ast)
{name, [:map], opts, [build_attribute(attributes_ast)]}
end

defp build_attribute({:attribute, _, [[name], [do: attributes_ast]]}) do
{name, [:map], [], [build_attribute(attributes_ast)]}
end
Expand All @@ -173,6 +178,11 @@ defmodule Mix.Tasks.Compile.Speck do
{name, :map, [], Enum.map(attributes_ast, &build_attribute/1)}
end

defp build_attribute({:attribute, _, [name, opts_ast, [do: attributes_ast]]}) do
{opts, _} = Code.eval_quoted(opts_ast)
{name, :map, opts, [build_attribute(attributes_ast)]}
end

defp build_attribute({:attribute, _, [name, [do: attributes_ast]]}) do
{name, :map, [], [build_attribute(attributes_ast)]}
end
Expand Down