Author: Manuel Jacob <m...@manueljacob.de> Branch: py3.6 Changeset: r94027:1938b1ea9975 Date: 2018-03-20 14:10 +0100 http://bitbucket.org/pypy/pypy/changeset/1938b1ea9975/
Log: Raise SyntaxError when 'return' with value is used inside an async generator. diff --git a/pypy/interpreter/astcompiler/symtable.py b/pypy/interpreter/astcompiler/symtable.py --- a/pypy/interpreter/astcompiler/symtable.py +++ b/pypy/interpreter/astcompiler/symtable.py @@ -263,6 +263,9 @@ def note_return(self, ret): if ret.value: + if self.is_coroutine and self.is_generator: + raise SyntaxError("'return' with value in async generator", + ret.lineno, ret.col_offset) self.return_with_value = True self.ret = ret diff --git a/pypy/interpreter/test/test_syntax.py b/pypy/interpreter/test/test_syntax.py --- a/pypy/interpreter/test/test_syntax.py +++ b/pypy/interpreter/test/test_syntax.py @@ -94,6 +94,10 @@ async def foo(): await await fut + async def foo(): + yield + return 42 + """) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit