Skip to content

Panics and stack overflows for infinitely growing parameter default types #1402

@sharkdp

Description

@sharkdp

On the type-of-self PR, we panic on setuptools due to an example similar to the following (minified and modified). This is also reproducible on main:

class C:
    def f(self: "C"):
        self.x = lambda a=self.x: a

I assume this happens because we build up an infinitely growing type for the type of the parameter default.

Lambdas are certainly not the only syntactical construct affected here. For example, this stack overflows:

class C:
    def f(self: "C"):
        def inner(a: int=self.x):
            return

        self.x = inner

reveal_type(C().f)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfatala fatal error (panic or crash)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions