Skip to content

decorate_arg errors out if arg_ast is not a tuple #36

Description

@imeraj

While playing with the code here, I encountered an issue in decorate_arg function -

if elem(arg_ast, 0) == :\\ do

Looks like if there is pattern matching like

  deftraceable foo(_, 0) do
    :error
  end

This line throws an error -

== Compilation error in file tracer_test.exs ==
** (ArgumentError) errors were found at the given arguments:

  * 2nd argument: not a tuple

    :erlang.element(1, 0)
    tracer.exs:55: Tracer.decorate_args/1
    (elixir 1.14.4) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.14.4) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    tracer.exs:50: Tracer.decorate_args/1
    tracer_test.exs:6: (module)

I had to make below change to make the code work -

if is_tuple(arg_ast) and elem(arg_ast, 0) == :\\ do

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions