Skip to content

Two crashes on recursive named tuples #3340

Closed
@ilevkivskyi

Description

@ilevkivskyi

While working on #3322 I have found two more crashes:

N = NamedTuple('N', [('x', N)])
n: N

crashes with RecursionError and

class N(NamedTuple):
    x: N
class M(NamedTuple):
    x: M

n: N
m: M
lst = [n, m]

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).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions