Skip to content

Commit

Permalink
Merge pull request #465 from newrelic/vince/tracer-macro-ignored-tail
Browse files Browse the repository at this point in the history
Tracer - Create a proper list when tail of list is ignored
  • Loading branch information
tpitale authored Jan 7, 2025
2 parents c51e943 + 7642285 commit da1819a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/new_relic/tracer/macro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ defmodule NewRelic.Tracer.Macro do
end
end

# Replace :__ignored__ with [] when it's the tail of a list so we don't create an improper list
def rewrite_call_term({:|, line, [left, :__ignored__]}) do
{:|, line, [left, []]}
end

def rewrite_call_term(term), do: term

def is_variable?({name, _, context}) when is_variable(name, context), do: true
Expand Down
14 changes: 14 additions & 0 deletions test/tracer_macro_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ defmodule NewRelic.Tracer.MacroTest do
assert expected == NewRelic.Tracer.Macro.build_call_args(ast)
end

test "create a proper list when ignoring tail of a list" do
ast =
quote do
[a | _ignored]
end

expected =
quote do
[a | []]
end

assert expected == NewRelic.Tracer.Macro.build_call_args(ast)
end

test "strip default values" do
ast =
quote do
Expand Down

0 comments on commit da1819a

Please sign in to comment.