MacroTools.jl
MacroTools.jl copied to clipboard
Pattern matching a namespaced type
It seems the pattern-matching syntax gets confused by the . in the type:
julia> using MacroTools, Markdown
julia> @capture(md"_hello_", x_Markdown.MD)
false
julia> using Markdown: MD
julia> @capture(md"_hello_", x_MD)
true
I can see why this is confusing, but it's unavoidable; the x_Markdown is actually parsed as all one symbol and @capture parses it further.