Skip to content

Bivariant class assignability is broken #3517

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

Ran into this while making my umpteenth generic parser generator soup and messed up a parser generator transformer.
https://play.ty.dev/ba3f04b2-0ba6-46de-a84c-b9e2d792ce89

class Container[T]: ...

def foo(x: Container[str]) -> Container[int]:
    return x  # <- Should error

Version

ty 0.0.35 (bc12d1c 2026-05-10) playground 7efc9a6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions