ruff/crates/ty_python_semantic/resources/mdtest/generics/legacy
Shunsuke Shibayama 5e42926eee
[ty] improve bad specialization results & error messages (#21840)
## Summary

This PR includes the following changes:

* When attempting to specialize a non-generic type (or a type that is
already specialized), the result is `Unknown`. Also, the error message
is improved.
* When an implicit type alias is incorrectly specialized, the result is
`Unknown`. Also, the error message is improved.
* When only some of the type alias bounds and constraints are not
satisfied, not all substitutions are `Unknown`.
* Double specialization is prohibited. e.g. `G[int][int]`

Furthermore, after applying this PR, the fuzzing tests for seeds 1052
and 4419, which panic in main, now pass.
This is because the false recursions on type variables have been
removed.

```python
# name_2[0] => Unknown
class name_1[name_2: name_2[0]]:
    def name_4(name_3: name_2, /):
        if name_3:
            pass

#  (name_5 if unique_name_0 else name_1)[0] => Unknown
def name_4[name_5: (name_5 if unique_name_0 else name_1)[0], **name_1](): ...
```

## Test Plan

New corpus test
mdtest files updated
2025-12-11 19:21:34 -08:00
..
classes.md [ty] avoid unions of generic aliases of the same class in fixpoint (#21909) 2025-12-11 09:53:43 -08:00
functions.md [ty] Uniformly use "not supported" in diagnostics (#21916) 2025-12-11 15:03:55 +00:00
paramspec.md [ty] improve bad specialization results & error messages (#21840) 2025-12-11 19:21:34 -08:00
variables.md [ty] Support `type[T]` with type variables (#21650) 2025-11-28 09:20:24 +01:00
variance.md [ty] eliminate is_fully_static (#18799) 2025-06-24 18:02:05 -07:00