diff --git a/hy/compiler.py b/hy/compiler.py index 2cffad1..318174b 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -453,11 +453,14 @@ class HyASTCompiler(object): return ast.Pass(lineno=expr.start_line, col_offset=expr.start_column) @builds("yield") - @checkargs(1) + @checkargs(max=1) def compile_yield_expression(self, expr): expr.pop(0) + value = None + if expr != []: + value = self.compile(expr.pop(0)) return ast.Yield( - value=self.compile(expr.pop(0)), + value=value, lineno=expr.start_line, col_offset=expr.start_column) diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index 1f5a7f9..05cf72b 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -210,7 +210,6 @@ def test_ast_good_yield(): def test_ast_bad_yield(): "Make sure AST can't compile invalid yield" - cant_compile("(yield)") cant_compile("(yield 1 2)")