Merge pull request #1886 from Kodiologist/empty-expr
Fixes for empty expressions
This commit is contained in:
commit
88f30c4b35
2
NEWS.rst
2
NEWS.rst
@ -13,6 +13,8 @@ Bug Fixes
|
|||||||
* Improved support for nesting anaphoric macros by only applying
|
* Improved support for nesting anaphoric macros by only applying
|
||||||
symbol replacement where absolutely necessary.
|
symbol replacement where absolutely necessary.
|
||||||
* Quoted f-strings are no longer evaluated prematurely.
|
* Quoted f-strings are no longer evaluated prematurely.
|
||||||
|
* Fixed a regression in the production of error messages for empty
|
||||||
|
expressions.
|
||||||
|
|
||||||
0.18.0
|
0.18.0
|
||||||
==============================
|
==============================
|
||||||
|
@ -308,10 +308,7 @@ def macroexpand(tree, module, compiler=None, once=False):
|
|||||||
|
|
||||||
assert not compiler or compiler.module == module
|
assert not compiler or compiler.module == module
|
||||||
|
|
||||||
while True:
|
while isinstance(tree, HyExpression) and tree:
|
||||||
|
|
||||||
if not isinstance(tree, HyExpression) or tree == []:
|
|
||||||
break
|
|
||||||
|
|
||||||
fn = tree[0]
|
fn = tree[0]
|
||||||
if fn in ("quote", "quasiquote") or not isinstance(fn, HySymbol):
|
if fn in ("quote", "quasiquote") or not isinstance(fn, HySymbol):
|
||||||
|
@ -7,7 +7,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from hy import HyString
|
from hy import HyString
|
||||||
from hy.compiler import hy_compile, hy_eval
|
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 import hy_parse
|
||||||
from hy.lex.exceptions import LexException, PrematureEndOfInput
|
from hy.lex.exceptions import LexException, PrematureEndOfInput
|
||||||
from hy._compat import PY36
|
from hy._compat import PY36
|
||||||
@ -36,14 +36,11 @@ def can_eval(expr):
|
|||||||
def cant_compile(expr):
|
def cant_compile(expr):
|
||||||
with pytest.raises(HyError) as excinfo:
|
with pytest.raises(HyError) as excinfo:
|
||||||
hy_compile(hy_parse(expr), __name__)
|
hy_compile(hy_parse(expr), __name__)
|
||||||
|
# Anything that can't be compiled should raise a user friendly
|
||||||
if issubclass(excinfo.type, HyLanguageError):
|
# error, otherwise it's a compiler bug.
|
||||||
assert excinfo.value.msg
|
assert issubclass(excinfo.type, HyLanguageError)
|
||||||
return excinfo.value
|
assert excinfo.value.msg
|
||||||
elif issubclass(excinfo.type, HyCompileError):
|
return excinfo.value
|
||||||
# Anything that can't be compiled should raise a user friendly
|
|
||||||
# error, otherwise it's a compiler bug.
|
|
||||||
return excinfo.value
|
|
||||||
|
|
||||||
|
|
||||||
def s(x):
|
def s(x):
|
||||||
|
Loading…
Reference in New Issue
Block a user