diff --git a/hy/compiler.py b/hy/compiler.py index f6e169a..8389b16 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -526,21 +526,26 @@ class HyASTCompiler(object): imports = set([name]) if isinstance(form, HyList): - contents = HyList() + if not form: + contents = HyList() + else: + # If there are arguments, they can be spliced + # so we build a sum... + contents = HyExpression([HySymbol("+"), HyList()]) + for x in form: f_imports, f_contents, splice = self._render_quoted_form(x, level) imports.update(f_imports) if splice: - contents = HyExpression([HySymbol('+'), - contents, - f_contents]) + to_add = f_contents else: - contents.append(f_contents) - return imports, HyExpression( - [HySymbol(name), - contents] - ).replace(form), False + to_add = HyList([f_contents]) + + contents.append(to_add) + + return imports, HyExpression([HySymbol(name), + contents]).replace(form), False elif isinstance(form, HySymbol): return imports, HyExpression([HySymbol(name), diff --git a/tests/native_tests/quote.hy b/tests/native_tests/quote.hy index 6114f4f..c886c2f 100644 --- a/tests/native_tests/quote.hy +++ b/tests/native_tests/quote.hy @@ -32,9 +32,10 @@ (defn test-unquote-splice [] "NATIVE: test splicing unquotes" (setf q (quote (c d e))) - (setf qq (quasiquote (a b (unquote-splice q)))) - (assert (= (len qq) 5)) - (assert (= qq (quote (a b c d e))))) + (setf qq (quasiquote (a b (unquote-splice q) f (unquote-splice q)))) + (assert (= (len qq) 9)) + (assert (= qq (quote (a b c d e f c d e))))) + (defn test-nested-quasiquote [] "NATIVE: test nested quasiquotes"