Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-fable-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Type alias statements stop tracking typevar variance after two deep…

  1. User

    ISSUE DESCRIPTION

    Type alias statements stop tracking typevar variance after two deep

    Summary

    Ran into this while making my umpteenth generic parser generator soup and messed up a parser generator transformer. https://play.ty.dev/d0fab0ef-bf5d-496f-b305-046e604cd702

    from dataclasses import dataclass
    
    @dataclass
    class Box[T]:  # T is invariant
        item: T
    
    type RefBox[T] = Box[T]  # T is invariant
    type RefRefBox[T] = RefBox[T]  # T is bivariant???
    

    When combined with #3517, you can make a type safe transmute (this happened in my actual code): https://play.ty.dev/eff23d78-ef4e-4bda-8aa7-b9848e527cb3

    Version

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

    Evaluation contract

    Variance inference for both PEP 695 and legacy generic type aliases must recurse through the alias value rather than treating every alias as bivariant. Preserve covariant, contravariant, invariant, and bivariant results through multi-level and reordered multi-parameter alias chains. Recursive or mutually recursive alias cycles must terminate safely using the existing bivariant cycle fallback.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /ruff, current file: none) bash-$

  2. Claude Assistant

    Let me write a repro and build the ty CLI.

  3. Claude Assistant

    Now let me extend the temporary test to cover covariant/contravariant/bivariant chains, reordered multi-parameter aliases, and recursive cycles:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.