diff --git a/NEWS.rst b/NEWS.rst index cabc57b..4270da5 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -51,6 +51,7 @@ Bug Fixes * Fixed a REPL crash caused by illegle unicode escape string inputs * `NaN` can no longer create an infinite loop during macro-expansion * Fixed a bug that caused `try` to drop expressions +* Fixed a bug where the compiler didn't properly compile `unquote-splice` Misc. Improvements ---------------------------- diff --git a/hy/compiler.py b/hy/compiler.py index e567d8d..cb2a3d1 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -723,7 +723,7 @@ class HyASTCompiler(object): ret.add_imports("hy", imports) return ret - @builds("unquote", "unquote-splicing") + @builds("unquote", "unquote-splice") def compile_unquote(self, expr): raise HyTypeError(expr, "`%s' can't be used at the top-level" % expr[0]) diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index c8d2999..9b9b16e 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -588,6 +588,16 @@ def test_setv_builtins(): """) +def test_top_level_unquote(): + with pytest.raises(HyTypeError) as excinfo: + can_compile("(unquote)") + assert excinfo.value.message == "`unquote' can't be used at the top-level" + + with pytest.raises(HyTypeError) as excinfo: + can_compile("(unquote-splice)") + assert excinfo.value.message == "`unquote-splice' can't be used at the top-level" + + def test_lots_of_comment_lines(): # https://github.com/hylang/hy/issues/1313 can_compile(1000 * ";\n")