ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[ty] Fix panic where we would incorrectly consider overloads in another file as belonging to a function in the file being checked

Open AlexWaygood opened this issue 2 weeks ago • 2 comments

Summary

Fixes https://github.com/astral-sh/ty/issues/1867. In certain cases where a function definition has not yet been completed, we can end up associating overloads from a totally different function (in a totally different file) with the unfinished function in the file being checked. That then leads us to panic in other places that assume (reasonably) that a function's overloads will all always be defined in a single file.

This PR fixes the panic by adding more sanity checks to OverloadLiteral::previous_overload().

Test Plan

Added a regression test that causes us to panic on main.

AlexWaygood avatar Dec 14 '25 16:12 AlexWaygood

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

astral-sh-bot[bot] avatar Dec 14 '25 16:12 astral-sh-bot[bot]

mypy_primer results

No ecosystem changes detected ✅

No memory usage changes detected ✅

astral-sh-bot[bot] avatar Dec 14 '25 16:12 astral-sh-bot[bot]