Mangle a macro until it stops moving

this helps if we use a macro in something that got tree-mangled
  back out.
This commit is contained in:
Paul R. Tagliamonte 2013-04-07 18:41:41 -04:00
parent 48ae1b1e26
commit e22a0ff73c
2 changed files with 11 additions and 3 deletions

View File

@ -31,9 +31,12 @@ MACROS = [
def process(tree):
load_macros()
tree = mprocess(tree)
for m in hy.mangle.MANGLES:
m().mangle(tree)
old = None
while old != tree:
old = tree
tree = mprocess(tree)
for m in hy.mangle.MANGLES:
m().mangle(tree)
return tree

View File

@ -377,6 +377,11 @@
(assert (= true (if true true true))))
(defn test-nested-mangles []
"NATIVE: test that we can use macros in mangled code"
(assert (= ((fn [] (-> 2 (+ 1 1) (* 1 2)))) 8)))
(defn test-let-scope []
"NATIVE: test let works rightish"
(setv y 123)