Don't macro-expand inside quotes
This commit is contained in:
parent
68399b9fc3
commit
2860ef6ff7
@ -36,6 +36,8 @@ def macro(name):
|
|||||||
def process(tree):
|
def process(tree):
|
||||||
if isinstance(tree, HyExpression):
|
if isinstance(tree, HyExpression):
|
||||||
fn = tree[0]
|
fn = tree[0]
|
||||||
|
if fn in ("quote", "quasiquote"):
|
||||||
|
return tree
|
||||||
ntree = HyExpression([fn] + [process(x) for x in tree[1:]])
|
ntree = HyExpression([fn] + [process(x) for x in tree[1:]])
|
||||||
ntree.replace(tree)
|
ntree.replace(tree)
|
||||||
|
|
||||||
|
@ -12,6 +12,15 @@
|
|||||||
(assert (= (cdr f) (quote (true true true)))))
|
(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 []
|
(defn test-quasiquote []
|
||||||
"NATIVE: test that quasiquote and quote are equivalent for simple cases"
|
"NATIVE: test that quasiquote and quote are equivalent for simple cases"
|
||||||
(setf q (quote (a b c)))
|
(setf q (quote (a b c)))
|
||||||
|
Loading…
Reference in New Issue
Block a user