Skip to content

Do not allow returns with arguments in generators #20

Closed

Description

@JukkaL

The following is accepted by the compiler, even though it is not valid in Python:

def f():
    yield 1
    return 1

There should be a compile error if mixing return with an argument and yield within the same function.

Update: only disallow this in Python 2 (see below).

Activity

  1. etrepum commented on Jul 22, 2014

    @etrepum
    Contributor

    This is invalid in Python 2 (and the existing Python 2.7.8 compiler will give you a SyntaxError for this), but valid in Python 3 due to PEP 380 http://legacy.python.org/dev/peps/pep-0380/

  2. JukkaL commented on Aug 24, 2014

    @JukkaL
    CollaboratorAuthor

    Okay, only disallow this in Python 2 mode?

  3. etrepum commented on Aug 25, 2014

    @etrepum
    Contributor

    Yeah, it's a feature and not a bug in Python 3 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions