You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
crashes with AssertionError in join_instances_via_supertype. I didn't try TypedDict but most probably it will have similar problems.
There is actually a fundamental question here: what should be the join(N, M)? @JukkaL do you have any ideas? One possible option would be to detect recursive joins and just return object for them (maybe also UninhabitedType for recursive meets).
The text was updated successfully, but these errors were encountered:
object would be consistent as the result of join(N, M). A recursive type like T where T = Tuple[T] would perhaps also be a reasonable result, assuming we were able to represent them. (The only reasonable common use case where recursive types could be useful that I've seen is JSON, so this is not a valid motivating example for recursive types.)
Forward references didn't work with anything apart from classes, for example
this didn't work:
```
x: A
A = NamedTuple('A', [('x', int)])
```
The same situation was with `TypedDict`, `NewType`, and type aliases. The
root problem is that these synthetic types are neither detected in first pass,
nor fixed in third pass. In certain cases this can lead to crashes (first six issues
below are various crash scenarios). This fixes these crashes by applying some
additional patches after third pass.
Here is the summary of the PR:
* New simple wrapper type `ForwardRef` with only one field `link` is introduced
(with updates to type visitors)
* When an unknown type is found in second pass, the corresponding
`UnboundType` is wrapped in `ForwardRef`, it is given a "second chance" in
third pass.
* After third pass I record the "suspicious" nodes, where forward references and
synthetic types have been encountered and append patches (callbacks) to fix
them after third pass. Patches use the new visitor `TypeReplacer` (which is the
core of this PR).
Fixes#3340Fixes#3419Fixes#3674Fixes#3685Fixes#3799Fixes#3836Fixes#3881Fixes#867Fixes#2241Fixes#2399Fixes#1701Fixes#3016Fixes#3054Fixes#2762Fixes#3575Fixes#3990
While working on #3322 I have found two more crashes:
crashes with
RecursionError
andcrashes with
AssertionError
injoin_instances_via_supertype
. I didn't tryTypedDict
but most probably it will have similar problems.There is actually a fundamental question here: what should be the
join(N, M)
? @JukkaL do you have any ideas? One possible option would be to detect recursive joins and just returnobject
for them (maybe alsoUninhabitedType
for recursive meets).The text was updated successfully, but these errors were encountered: