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

Code snippet freezes pyright #4424

Closed
tomhampshire opened this issue Jan 9, 2023 · 4 comments
Closed

Code snippet freezes pyright #4424

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

Comments

@tomhampshire
Copy link

Running pyright on the included code snippet causes pyright to run infinitely.

Describe the bug
Running pyright on the included code snippet causes pyright to run infinitely. The code itself has been minimised as much as possible, and is nonsensical.

To Reproduce
Put the code in a file and run pyright from the command line (uses pyright 1.1.287 on Arch Linux). Tested with Python 3.10.9 and Python 3.9.16.

Expected behavior
pyright should finish running.

Screenshots or Code

def function_a():
    function_b([])


def function_b(input_list):
    output_tuple = ()

    for _, value in enumerate([]):
        if value is None:
            output_tuple += (None,)
            continue
        output_tuple += (input_list[value],)

    return output_tuple

VS Code extension or command-line
pyright 1.1.287 from the Arch Linux community/pyright 1.1.287-1

@erictraut erictraut added the bug Something isn't working label Jan 9, 2023
@erictraut
Copy link
Collaborator

Thanks for the bug report. I've found the underlying cause, but I'm still working out a fix. The issue is that every time through the loop, a new tuple type is produced for output_tuple. This gets unioned with the tuple types from the previous loop passes. The type never converges to a single type. It simply adds more and more subtypes to the union.

erictraut pushed a commit that referenced this issue Jan 12, 2023
@erictraut
Copy link
Collaborator

I found a reasonable fix. This will be included in the next release.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jan 12, 2023
@erictraut
Copy link
Collaborator

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

@tomhampshire
Copy link
Author

Thanks for looking into and fixing this!

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