What's worng with this pattern match

Hello,
I’m trying to pattern match this part

{:@, [line: 2, column: 3],
          [{:doc, [line: 2, column: 4], ["  Adds 2 numbers\n"]}]},
         {:def, [line: 5, column: 3],

from this:
image
just the :defmodule block without the :ok

I’m using this pattern match in the functions that receives the structure:

  defp traverse(
         {:@, _, _},
         {:def, meta, [{name, _, args} | _]} = ast,
         issues,
         specs,
         issue_meta
       ) do

also:

defp traverse(
         [{:@, _, _},{:def, meta, _} | _] = ast,
         issues,
         specs,
         issue_meta
       ) do

With no success, and I can’t find what’s wrong.

Any suggestion please? Thanks in advice!!!

1 Like

While I can’t see the real use case of your traverse/x function, I don’t know how your target data is fed into the function, so I have no idea why it doesn’t work.

But you can check your patterns by calling Kernel.match?/2
I hope this can help you figure it out.

hi, thank you for your answer I will see