FluxML / MacroTools.jl

MacroTools provides a library of tools for working with Julia code and expressions.
https://fluxml.ai/MacroTools.jl/stable/
Other
310 stars 79 forks source link

@capture union problem #180

Open cstjean opened 2 years ago

cstjean commented 2 years ago

Similar to what was noted in https://github.com/FluxML/MacroTools.jl/issues/40#issuecomment-357466077,

julia> @capture :(myvariable = 2) (lhs_Symbol = rhs_)
true

julia> @capture :(myvariable = 2) (lhs_Symbol = rhs_) | someotherpat
false

julia> @capture :(myvariable = 2) (lhs_ = rhs_) | someotherpat
true

The second match should be true as well.

heyx3 commented 11 months ago

There's a much simpler example:

julia> @capture(:x, a_Symbol)
true

julia> @capture(:x, (a_Symbol) | (a_::b_))
false