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

False positive '"yield" not allowed outside of a function' when using yield in lambda in top-level code #373

Closed
tonywu7 opened this issue Sep 15, 2020 · 2 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@tonywu7
Copy link

tonywu7 commented Sep 15, 2020

Environment data

  • Language Server version: v2020.9.4
  • OS and version: macOS 10.15.6
  • Python version: Python 3.8.1

Expected behaviour

Writing a lambda function containing yield expressions in top-level code should be considered valid syntax.

Actual behaviour

Pylance reports "yield" not allowed outside of a function for the yield expression.

Code Snippet / Additional information

Can be reproduced simply with

lambda: (yield)
@erictraut
Copy link
Contributor

Thanks for the bug report. I didn't realize that yield statements could be used within lambdas. I've updated the code to not emit an error in this case. This fix will be in the next release of pylance.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version labels Sep 16, 2020
@github-actions github-actions bot removed the triage label Sep 16, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.5, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202095-16-september-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants