-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
recursive type with Union causes RuntimeError: Internal error: unresolved forward reference #4200
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
Comments
This is a manifestation of #3977 (calling @JukkaL what do you think we should do? Maybe just add another round of patches? Currently all patches are in one "pile" (in a list actually, so they are ordered), I was thinking about having separate rounds, for example:
EDIT: fixed second sentence, thanks @elazarg |
@ilevkivskyi What about adding a priority number to the patches? We'd sort the patches by their priority before applying them. |
OK, makes sense. |
@ilevkivskyi Are you working on this? I can also look at this if you are busy. |
@JukkaL No, sorry, last two weeks were too busy. It would be great if you take care of this. |
Another repro for this crash reported in #4381: from typing import List, NewType, Union
N = NewType('N', XXX)
x: List[Union[N, int]] |
I'm going to look at this since this is interfering with some of my experiments and seems relatively easy to trigger through skipped imports. |
Move type variable checks which use subtype and type sameness checks to happen at the end of semantic analysis. The implementation also adds the concept of priorities to semantic analysis patch callbacks. Callback calls are sorted by the priority. We resolve forward references and calculate fallbacks before checking type variable values, as otherwise the latter could see incomplete types and crash. Fixes #4200.
Another complex repro was reported in #4385 |
Move type variable checks which use subtype and type sameness checks to happen at the end of semantic analysis. The implementation also adds the concept of priorities to semantic analysis patch callbacks. Callback calls are sorted by the priority. We resolve forward references and calculate fallbacks before checking type variable values, as otherwise the latter could see incomplete types and crash. Fixes #4200.
Run mypy (0.540) on the following code
This generates the following:
Note that I understand that recursive types are not yet supported and I get the more friendly message stating such if I define one that does not involve the Union.
The text was updated successfully, but these errors were encountered: