Both of these are invalid on every Python version I've tried and should be flagged as ParseErrors in the parser:
def f(): yield *rest
def f(): return *rest
They result in SyntaxError: can't use starred expression here on 3.8 and 3.13 and the less helpful SyntaxError: invalid syntax on 3.7.
This is separate from the related case in #16485 where these are part of a tuple, which is allowed after 3.8.
Originally posted by @ntBre in #16485 (comment)
Both of these are invalid on every Python version I've tried and should be flagged as
ParseErrors in the parser:They result in
SyntaxError: can't use starred expression hereon 3.8 and 3.13 and the less helpfulSyntaxError: invalid syntaxon 3.7.This is separate from the related case in #16485 where these are part of a tuple, which is allowed after 3.8.
Originally posted by @ntBre in #16485 (comment)