Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow returns with arguments in generators #20

Closed
JukkaL opened this issue Dec 13, 2012 · 3 comments · Fixed by #1137
Closed

Do not allow returns with arguments in generators #20

JukkaL opened this issue Dec 13, 2012 · 3 comments · Fixed by #1137
Labels
bug mypy got something wrong

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 13, 2012

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

@JukkaL JukkaL added the easy label Jul 14, 2014
@etrepum
Copy link
Contributor

etrepum commented Jul 22, 2014

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/

@JukkaL JukkaL removed the front end label Jul 25, 2014
@JukkaL
Copy link
Collaborator Author

JukkaL commented Aug 24, 2014

Okay, only disallow this in Python 2 mode?

@etrepum
Copy link
Contributor

etrepum commented Aug 25, 2014

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
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants