#4607·ty

Cycle-iteration panic for a recursive type alias used in a decorator

Author: AlexWaygoodCreated Sep 28, 2026Updated Sep 30, 2026
Labelsbugfatalhangfuzzertype aliasescyclesregression

The following file causes ty to spend several seconds checking it and then panic:

python
value = lambda: value
try:
    type Alias = value
finally:
    @[Alias]
    class Example:
        pass
    value = Example
bash
ty check repro.py --python-version 3.12 --python-platform linux

On Ruff revision 0fa37a3c33, ty exits with an error[panic] reporting infer_scope_types_impl: execute: too many cycle iterations. The file contains an invalid type expression and an invalid decorator; ty should report the relevant diagnostics and finish.

This is a regression at Ruff commit a8d3850605, introduced by #24705. The immediately preceding commit completes the example with two diagnostics; the introducing commit did not complete within 30 seconds.

This example was minimized from the Python source generated by py-fuzzer with seed 1246.

The full default output on Ruff revision 0fa37a3c33 (local paths shortened):

error[panic]: Panicked at <cargo-registry>/salsa-0.28.5/src/function/execute.rs:751:9 when checking `repro.py`: `infer_scope_types_impl(Id(382)): execute: too many cycle iterations`
info: This indicates a bug in ty.
info: If you could open an issue at https://github.com/astral-sh/ty/issues/new?title=%5Bpanic%5D, we'd be very appreciative!
info: Platform: macos aarch64
info: Version: ruff/0.16.9+32 (0fa37a3c3 2026-09-28)
info: Args: ["ty", "check", "repro.py", "--python-version", "3.12", "--python-platform", "linux"]
info: run with `RUST_BACKTRACE=1` environment variable to show the full backtrace information
info: query stacktrace:
   0: infer_scope_types_impl(Id(382))
             at crates/ty_python_semantic/src/types/infer.rs:520
   1: PEP695TypeAliasType < 'db >::raw_value_type_(Id(2c80))
             at crates/ty_python_semantic/src/types/type_alias.rs:213
   2: cycle_summary(Id(2d00))
             at crates/ty_python_semantic/src/types/type_alias.rs:472
   3: infer_definition_types(Id(402))
             at crates/ty_python_semantic/src/types/infer.rs:234
   4: infer_definition_types(Id(403))
             at crates/ty_python_semantic/src/types/infer.rs:234
   5: place_by_id(Id(a00))
             at crates/ty_python_semantic/src/place.rs:1264
             cycle heads: infer_definition_types(Id(400)) -> iteration = 200
   6: infer_scope_types_impl(Id(381))
             at crates/ty_python_semantic/src/types/infer.rs:520
   7: infer_definition_types(Id(400))
             at crates/ty_python_semantic/src/types/infer.rs:234
   8: infer_scope_types_impl(Id(380))
             at crates/ty_python_semantic/src/types/infer.rs:520
   9: check_file_impl(Id(300))
             at crates/ty_project/src/lib.rs:959

Found 1 diagnostic
WARN A fatal error occurred while checking some files. Not all project files were analyzed. See the diagnostics list above for details.