diff --git a/hy/macros.py b/hy/macros.py index 3eda0c7..ca35aa6 100644 --- a/hy/macros.py +++ b/hy/macros.py @@ -36,6 +36,8 @@ def macro(name): def process(tree): if isinstance(tree, HyExpression): fn = tree[0] + if fn in ("quote", "quasiquote"): + return tree ntree = HyExpression([fn] + [process(x) for x in tree[1:]]) ntree.replace(tree) diff --git a/tests/native_tests/quote.hy b/tests/native_tests/quote.hy index c886c2f..0b64f3d 100644 --- a/tests/native_tests/quote.hy +++ b/tests/native_tests/quote.hy @@ -12,6 +12,15 @@ (assert (= (cdr f) (quote (true true true))))) +(defn test-quoted-macroexpand [] + "NATIVE: check that we don't expand macros in quoted expressions" + (setf q1 (quote (-> a b c))) + (setf q2 (quasiquote (-> a b c))) + (assert (= q1 q2)) + (assert (= (car q1) (quote ->))) + (assert (= (cdr q1) (quote (a b c))))) + + (defn test-quasiquote [] "NATIVE: test that quasiquote and quote are equivalent for simple cases" (setf q (quote (a b c)))