Skip to content

Class with varadic generic/typevartuple can be considered not assignable to itself #4606

Description

@MeGaGiGaGon

Describe the Bug

class A[*TS]:
    def __init__(self, *state: *TS):
        self.state: tuple[*TS] = state
    
    def add[*TR](self: A[*TR, int, int]) -> A[*TR, int]:
        # ERROR sandbox.py:6:16-68: Returned type `A[*TR, int]` is not assignable to declared return type `A[*TR, int]` [bad-return]
        return A(*self.state[:-2], self.state[-2] + self.state[-1])

Python: 3.14

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.jZTNDoIwEIRfZRMOGPxpNIaY3jx41lRv2ES0RL2IkerzO10kBQUiBxK27bLd_Wa6LLOUyjKJdlvdrZQIAFkgil11clgfnyX7hNY4DernWLnP50yNwbrSnFPyP9UIs4XJ4aWZIR-sqnFPQCul1op85TKW03gcLyQppjczzvczOtQSHJxE0GPnqmi6c0GyOUrBndHxivuWc8kxNZiMW8Ykv3SyHET-3okczzQU5QP4pmEjMNXA9JeigDZloLoW_BP4nZ9waWA12d8CGHRGF2vvhRSiOp4_ziK7CZOfCtE4IcgJJn2lV_b-ZjrKmfoCadvxnf-Fb1jSG_bBGzp2w14a3w

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions