Merge pull request #1886 from Kodiologist/empty-expr

Fixes for empty expressions
This commit is contained in:
Kodi Arfer 2020-04-03 14:29:23 -04:00 committed by GitHub
commit 88f30c4b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 13 deletions

View File

@ -13,6 +13,8 @@ Bug Fixes
* Improved support for nesting anaphoric macros by only applying
symbol replacement where absolutely necessary.
* Quoted f-strings are no longer evaluated prematurely.
* Fixed a regression in the production of error messages for empty
expressions.
0.18.0
==============================

View File

@ -308,10 +308,7 @@ def macroexpand(tree, module, compiler=None, once=False):
assert not compiler or compiler.module == module
while True:
if not isinstance(tree, HyExpression) or tree == []:
break
while isinstance(tree, HyExpression) and tree:
fn = tree[0]
if fn in ("quote", "quasiquote") or not isinstance(fn, HySymbol):

View File

@ -7,7 +7,7 @@ from __future__ import unicode_literals
from hy import HyString
from hy.compiler import hy_compile, hy_eval
from hy.errors import HyCompileError, HyLanguageError, HyError
from hy.errors import HyLanguageError, HyError
from hy.lex import hy_parse
from hy.lex.exceptions import LexException, PrematureEndOfInput
from hy._compat import PY36
@ -36,13 +36,10 @@ def can_eval(expr):
def cant_compile(expr):
with pytest.raises(HyError) as excinfo:
hy_compile(hy_parse(expr), __name__)
if issubclass(excinfo.type, HyLanguageError):
assert excinfo.value.msg
return excinfo.value
elif issubclass(excinfo.type, HyCompileError):
# Anything that can't be compiled should raise a user friendly
# error, otherwise it's a compiler bug.
assert issubclass(excinfo.type, HyLanguageError)
assert excinfo.value.msg
return excinfo.value