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

Regression in type inference when using list comprehension in a loop #4459

Closed
Molkree opened this issue Jan 15, 2023 · 2 comments
Closed

Regression in type inference when using list comprehension in a loop #4459

Molkree opened this issue Jan 15, 2023 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@Molkree
Copy link
Contributor

Molkree commented Jan 15, 2023

Describe the bug
Pyright can't infer correct type if I use list comprehension in a loop. Regression introduced in 1.1.286.

Expected behavior
No errors reported.

Screenshots or Code

lst = [1]  # no error if I add explicit type annotation here (lst: list[int] = [1])
while True:
    lst = [val for val in lst]

image

VS Code extension or command-line
VSC Pylance since v2023.1.11 and up to v2023.1.21, VSC Pyright since 1.1.286 and up to 1.1.289.

erictraut pushed a commit that referenced this issue Jan 15, 2023
…aluating a list comprehension in a loop. This addresses #4459.
@erictraut
Copy link
Collaborator

Thanks for the bug report. This will be addressed in the next release.

@erictraut erictraut added bug Something isn't working addressed in next version Issue is fixed and will appear in next published version labels Jan 15, 2023
@erictraut
Copy link
Collaborator

This is included in pyright 1.1.290, which I just published. It will also be included in a future release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants