Skip to content

Flag starred expressions in return and yield #16520

Closed
@ntBre

Description

@ntBre

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparserRelated to the parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions