diff --git a/hy/core/bootstrap.py b/hy/core/bootstrap.py index 18f4cd5..2b9f458 100644 --- a/hy/core/bootstrap.py +++ b/hy/core/bootstrap.py @@ -49,11 +49,13 @@ def cond_macro(tree): @macro("_>") def threading_macro(tree): - tree.pop(0) # -> - tree.reverse() + tree.pop(0) ret = tree.pop(0) - root = ret for node in tree: - ret.insert(1, node) + if not isinstance(node, HyExpression): + nnode = HyExpression([node]) + nnode.replace(node) + node = nnode + node.insert(1, ret) ret = node - return root + return ret diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index ce82231..a591325 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -139,6 +139,12 @@ ["X" "B" "C" "D"]))) +(defn test-threading-two [] + "NATIVE: test threading macro" + (assert (= (-> "a b c d" .upper (.replace "A" "X") .split) + ["X" "B" "C" "D"]))) + + (defn test-assoc [] "NATIVE: test assoc" (def vals {"one" "two"})