Skip to content
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

Can't match nested symbols #32

Closed
jamii opened this issue Sep 13, 2016 · 2 comments
Closed

Can't match nested symbols #32

jamii opened this issue Sep 13, 2016 · 2 comments

Comments

@jamii
Copy link

jamii commented Sep 13, 2016

@match :(@when a < b) begin
  Expr(_, [Symbol("@when"), _], _) => :ok
  Expr(_, [other, _], _) => other
end
# returns Symbol("@when")

Using Julia 0.5.0-rc4+0 and Match 0.2.2

@thautwarm
Copy link

thautwarm commented Feb 1, 2019

@jamii
It can be matched, the reason for your prob is, @m has an AST formed as Expr(:macrocall, Symbol("@m"), ::LineNumberNode, <args...>), while you missed the LineNumberNode.

@gafter
Copy link
Member

gafter commented Aug 3, 2023

julia> Pkg.status()
      Status `~/.julia/environments/v1.6/Project.toml`
  [7eb4fadd] Match v2.0.0

julia> @match :(@when a < b) begin
         Expr(_, [Symbol("@when"), _], _) => :ok
         Expr(_, [other, _], _) => other
       end
ERROR: LoadError: REPL[59]:2: The type `Expr` has 2 fields but the pattern expects 3 fields.

julia> @match :(@when a < b) begin
         Expr(_, [Symbol("@when"), _::LineNumberNode, _]) => :ok
         Expr(_, [other, _, _]) => other
       end
:ok

@gafter gafter closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants