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

An internal error occurred while type checking file: RangeError: Maximum call stack size exceeded #825

Closed
harenbrs opened this issue Jan 12, 2021 · 8 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@harenbrs
Copy link

Environment data

  • Language Server version: 2021.1.0
  • OS and version: macOS Big Sur 11.1 (20C69)
  • Python version: Python 3.8.6 (non-conda, installed with Pythonz)

Expected behaviour

Type checking functions correctly

Actual behaviour

Type checking throws an error at the top of the file

Logs

An internal error occurred while type checking file "/Users/seb/path/to/file.py": RangeError: Maximum call stack size exceeded
    at Object.lookUpClassMember (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeUtils.ts:711:17)
    at forEach (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:14900:34)
    at Map.forEach (<anonymous>)
    at canAssignClassToProtocol (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:14897:25)
    at canAssignClass (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15205:20)
    at canAssignType (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16198:22)
    at partiallySpecializeFunctionForBoundClassOrObject (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:17524:25)
    at bindFunctionToClassOrObject (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:17392:24)
    at /Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.0/dist/pyright-internal/src/analyzer/typeEvaluator.ts:14958:63
    at Map.forEach (<anonymous>)Pylance

Code Snippet / Additional information

Code is closed source at the moment, and I haven't been able to find a minimum-reproducible example.

The stack trace to my eyes looks different from the recently closed similar issues.

@erictraut
Copy link
Contributor

Thanks for reporting the bug.

We've identified and fixed one potential cause for this. Please try the next release of Pylance (which should be published in the next couple of days) and let us know if you still see the problem.

@judej judej added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jan 12, 2021
@github-actions github-actions bot removed the triage label Jan 12, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.1.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202111-13-january-2021

@harenbrs
Copy link
Author

I am now on Pylance language server 2021.1.1 (pyright 6a970b45) but I am still experiencing this error on Python 3.8.6, as well as an apparently different error on 3.9.1.

I have since published the "offending" source code here. Open the file pyclee/clusters.py for analysis.

Stack trace for 3.8.6:

An internal error occurred while type checking file "/Users/seb/tmp/pyclee/pyclee/clusters.py": RangeError: Maximum call stack size exceeded
    at Object.lookUpClassMember (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeUtils.ts:711:17)
    at forEach (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:14970:34)
    at Map.forEach (<anonymous>)
    at canAssignClassToProtocol (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:14953:25)
    at canAssignClass (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15383:20)
    at canAssignType (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16386:22)
    at partiallySpecializeFunctionForBoundClassOrObject (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:17723:25)
    at bindFunctionToClassOrObject (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:17591:24)
    at /Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15019:63
    at Map.forEach (<anonymous>)Pylance

Stack trace for 3.9.1:

An internal error occurred while type checking file "/Users/seb/tmp/pyclee/pyclee/clusters.py": RangeError: Maximum call stack size exceeded
    at canAssignClass (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15350:14)
    at canAssignType (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16386:22)
    at assignTypeToTypeVar (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15936:18)
    at canAssignType (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16056:24)
    at partiallySpecializeFunctionForBoundClassOrObject (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:17723:25)
    at bindFunctionToClassOrObject (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:17591:24)
    at forEach (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15009:58)
    at Map.forEach (<anonymous>)
    at canAssignClassToProtocol (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:14953:25)
    at Fn (/Users/seb/.vscode/extensions/ms-python.vscode-pylance-2021.1.1/dist/pyright-internal/src/analyzer/typeEvaluator.ts:15383:20)Pylance

@erictraut
Copy link
Contributor

@harenbrs, thanks for the repro steps. I was able to find and fix the problem. You are using NewType with a protocol class, which is something we've never seen before. That was causing infinite recursion within the type analyzer. The fix will be included in the next release.

@erictraut erictraut reopened this Jan 16, 2021
@harenbrs
Copy link
Author

Excellent, many thanks for dealing with it so quickly. Also happy to be making history, of a kind 😉

@jakebailey
Copy link
Member

This issue has been fixed in version 2021.1.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202112-20-january-2021

@AW1534
Copy link

AW1534 commented Feb 27, 2021

dont think its been resolved as im having that issue right now.

@erictraut
Copy link
Contributor

The original bug was definitely fixed. If you're experiencing a similar symptom, please file a new bug. And if you can provide a minimal code snippet that exhibits the problem, that would be really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

5 participants