Skip to content

[Panic] Too many cycle iterations #3080

@varchasgopalaswamy

Description

@varchasgopalaswamy

Summary

I have no settings in pyproject.toml for ty. I get the following error when checking my code. There did seem to be a bunch of issues here with a similar error. I am not an expert, but it didn't seem like any of them shared the same root cause.

error[panic]: Panicked at /root/.cargo/git/checkouts/salsa-e6f3bb7c2a062968/53421c2/src/function/execute.rs:633:9 when checking `.../test.py`: `is_equivalent_to_object_inner(Id(b801)): 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: linux x86_64
info: Version: 0.0.23
info: Args: ["ty", "check", ".../test.py"]
info: run with `RUST_BACKTRACE=1` environment variable to show the full backtrace information
info: query stacktrace:
   0: is_redundant_with_impl(Id(a80b))
             at crates/ty_python_semantic/src/types/relation.rs:504
   1: infer_deferred_types(Id(1412))
             at crates/ty_python_semantic/src/types/infer.rs:109
   2: FunctionType < 'db >::signature_(Id(6406))
             at crates/ty_python_semantic/src/types/function.rs:917
   3: Type < 'db >::apply_specialization_(Id(400a))
             at crates/ty_python_semantic/src/types.rs:761
   4: cached_protocol_interface(Id(b400))
             at crates/ty_python_semantic/src/types/protocol_class.rs:897
   5: is_equivalent_to_object_inner(Id(b800))
             at crates/ty_python_semantic/src/types/instance.rs:726
   6: is_redundant_with_impl(Id(a803))
             at crates/ty_python_semantic/src/types/relation.rs:504
   7: infer_deferred_types(Id(140b))
             at crates/ty_python_semantic/src/types/infer.rs:109
   8: FunctionType < 'db >::signature_(Id(6404))
             at crates/ty_python_semantic/src/types/function.rs:917
   9: cached_protocol_interface(Id(340c))
             at crates/ty_python_semantic/src/types/protocol_class.rs:897
  10: infer_scope_types_impl(Id(1000))
             at crates/ty_python_semantic/src/types/infer.rs:187
  11: check_file_impl(Id(c00))
             at crates/ty_project/src/lib.rs:594

A minimal reproducer is

from __future__ import annotations

from typing import Generic, Protocol, Self, TypeVar, overload

S = TypeVar("S")
T = TypeVar("T", covariant=True)


class Unit(Protocol):
    def __mul__(self, other: S | Quantity[S]) -> Quantity[S]: ...


class Vector(Protocol): ...


class Quantity(Generic[T], Protocol):
    def to(self, unit: str | Unit) -> Self: ...

    @property
    def m(self) -> T: ...

    @overload
    def __mul__(
        self: Quantity[S], other: Unit | float | int | Quantity[S]
    ) -> Quantity[S]: ...

    @overload
    def __mul__(self: Quantity[S], other: S | Vector) -> Vector: ...

Version

0.0.23

Metadata

Metadata

Assignees

Labels

ProtocolsbugSomething isn't workingfatala fatal error (panic or crash)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions