Don't macro-expand inside quotes

This commit is contained in:
Nicolas Dandrimont 2013-05-11 00:29:42 +02:00
parent 68399b9fc3
commit 2860ef6ff7
2 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -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)))