From e22a0ff73c8e567ae4ed58be659b3e2c2927cd22 Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Sun, 7 Apr 2013 18:41:41 -0400 Subject: [PATCH] Mangle a macro until it stops moving this helps if we use a macro in something that got tree-mangled back out. --- hy/core/__init__.py | 9 ++++++--- tests/native_tests/language.hy | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hy/core/__init__.py b/hy/core/__init__.py index a17b72c..65be1af 100644 --- a/hy/core/__init__.py +++ b/hy/core/__init__.py @@ -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 diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 9eaf0f5..5beaf6f 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -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)