Updating yield.

This commit is contained in:
Paul R. Tagliamonte 2013-04-12 23:48:58 -04:00
parent 454323ae04
commit f295b10f52
2 changed files with 5 additions and 3 deletions

View File

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

View File

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