From fdb014440216d227f4942f54456211318ebba08d Mon Sep 17 00:00:00 2001 From: Ben Murphy Date: Mon, 28 Apr 2025 14:55:00 -0400 Subject: [PATCH] Build attributes AST for non-:__block__ container attributes with opts --- lib/mix/tasks/compiler.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/mix/tasks/compiler.ex b/lib/mix/tasks/compiler.ex index 01645b3..729ad9d 100644 --- a/lib/mix/tasks/compiler.ex +++ b/lib/mix/tasks/compiler.ex @@ -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 @@ -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