MacroTools.jl icon indicating copy to clipboard operation
MacroTools.jl copied to clipboard

order in unions

Open tpapp opened this issue 7 years ago • 1 comments

Not sure if this is a documentation issue or a bug, but order matters:

julia> (@capture :(struct Foo{X} end) struct (T_{params__}|T_) fields__ end), T
(true, :Foo)

julia> (@capture :(struct Foo{X} end) struct (T_|T_{params__}) fields__ end), T
(true, :(Foo{X}))

tpapp avatar Sep 08 '18 09:09 tpapp

Yes, this is just something we should document. MacroTools is more like a regex than a CSS selector; it doesn't have any concept of "better" matches and just takes the first valid one.

MikeInnes avatar Nov 05 '18 12:11 MikeInnes