MacroTools.jl
MacroTools.jl copied to clipboard
order in unions
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}))
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.