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

Evaluated type of expression varies based on evaluation order #2983

Closed
erictraut opened this issue Feb 4, 2022 · 3 comments
Closed

Evaluated type of expression varies based on evaluation order #2983

erictraut opened this issue Feb 4, 2022 · 3 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@erictraut
Copy link
Collaborator

This is a tracking bug. The original is found here: microsoft/pylance-release#2324.

The evaluated type of the return expression depends on the order of evaluation. It should be order invariant.

To repro, hover over the e in the return statement while modifying the file. The hover will cause the e in the return statement to be evaluated prior to the other statements, and the inferred return type will be evaluated as Literal[0] rather than the correct answer of Unknown | Literal[0].

def f(x):
    e = 0
    for _ in [0]:
        e += x
    return e
@erictraut erictraut added the bug Something isn't working label Feb 4, 2022
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Mar 8, 2022
@erictraut
Copy link
Collaborator Author

This is addressed in pyright 1.1.228, which I just published. It will also be included in the next release of pylance.

@erictraut erictraut reopened this Mar 18, 2022
@erictraut
Copy link
Collaborator Author

Reopening for investigation because user reports that it's still a problem.

@erictraut erictraut added needs investigation Requires additional investigation to determine course of action bug Something isn't working and removed bug Something isn't working addressed in next version Issue is fixed and will appear in next published version needs investigation Requires additional investigation to determine course of action labels Mar 18, 2022
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Mar 27, 2022
@erictraut
Copy link
Collaborator Author

This is included in pyright 1.1.233, which I just published. It will also be included in the next 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

1 participant