Skip to content

Extremely big stringification for functions with a return type of itself #2922

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

Found this while messing a round, you get extremely big stringifications for these types of functions:
https://play.ty.dev/7ff4f217-5399-45a4-974d-09eccada008c

from ty_extensions import TypeOf
def foo[T]() -> TypeOf[foo]:
    return foo
reveal_type(foo)

Gives 1139 chars

Revealed type: `def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> def foo[T]() -> Any` (revealed-type) [Ln 4, Col 13]

This code crashes eventually from running out of memory

from ty_extensions import TypeOf
def foo[T]() -> TypeOf[foo]:
    return foo
def foo[T]() -> TypeOf[foo]:
    return foo
reveal_type(foo)

The length of the reveal on this expoentiates per def:
https://play.ty.dev/33601387-786f-49d7-875a-913e98211871

from ty_extensions import TypeOf
def foo() -> TypeOf[foo]:
    return foo
def foo() -> TypeOf[foo]:
    return foo
def foo() -> TypeOf[foo]:
    return foo
def foo() -> TypeOf[foo]:
    return foo
reveal_type(foo)

Version

ty 0.0.19 (ae10022 2026-02-26) playground cb2035aec

Metadata

Metadata

Assignees

Labels

fatala fatal error (panic or crash)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions