From 48dd9684612170636d89f2c40a1e72248ae93432 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Sun, 22 Sep 2013 15:08:43 +0200 Subject: [PATCH 1/2] Coerce the contents of unquote-splice'd things to a list This fixes the conversion issue in the following macro: (defmacro doodle [&rest body] `(do ~@body)) --- hy/compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hy/compiler.py b/hy/compiler.py index 90ad043..bfe48a4 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -610,7 +610,7 @@ class HyASTCompiler(object): level) imports.update(f_imports) if splice: - to_add = f_contents + to_add = HyExpression([HySymbol("list"), f_contents]) else: to_add = HyList([f_contents]) From 6a7d97c286595a4e71e6b74a30222e02423785ed Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Sun, 22 Sep 2013 15:12:59 +0200 Subject: [PATCH 2/2] Add test for unquote-splice behavior --- tests/native_tests/quote.hy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/native_tests/quote.hy b/tests/native_tests/quote.hy index 45c7648..8900578 100644 --- a/tests/native_tests/quote.hy +++ b/tests/native_tests/quote.hy @@ -82,3 +82,14 @@ (setv opt (quote &optional)) (assert (isinstance opt hy.HyLambdaListKeyword)) (assert (= (str opt) "&optional"))) + +(defmacro doodle [&rest body] + `(do ~@body)) + +(defn test-unquote-splice [] + "NATIVE: test unquote-splice does what's intended" + (assert (= + (doodle + [1 2 3] + [4 5 6]) + [4 5 6])))