Merge pull request #1579 from vodik/splicing-typo

Fix a bug where the compiler doesn't properly handle unquote-splice
This commit is contained in:
Kodi Arfer 2018-04-30 09:46:42 -07:00 committed by GitHub
commit bb10921ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -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
----------------------------

View File

@ -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])

View File

@ -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")