diff --git a/docs/src/pattern-matching.md b/docs/src/pattern-matching.md index 0cc53eb..078ea6f 100644 --- a/docs/src/pattern-matching.md +++ b/docs/src/pattern-matching.md @@ -91,6 +91,20 @@ Another common use case is to catch symbol literals, e.g. which will match e.g. `struct Foo ...` but not `struct Foo{V} ...` +If you want to match on quoted symbols like `:(:a)` you might look at the AST Julia +produces and expect to be able to use the type `QuoteNode` in your pattern. Hence, +you would expect the following to produce `1`: + +```julia +@match :(:a) begin + s_QuoteNode => 1 + s_quote => 2 +end +``` +However, it evaluates to `2` because MacroTools normalizes expressions before comparing +them to your pattern. And `QuoteNode` gets normalized to `quote` so to match a quoted +symbol you will need `@capture(ex, s_quote) && s.args[1] isa Symbol` + ### Unions `@capture` can also try to match the expression against one pattern or another,