Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Fix panic from imported overload definition#25168

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/cont
May 14, 2026
Merged

[ty] Fix panic from imported overload definition#25168
charliermarsh merged 1 commit into
mainfrom
charlie/cont

Conversation

@charliermarsh

@charliermarsh charliermarsh commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

Prior to this change, the post-inference overload checks could panic when a local overload definition was shadowed by an imported overloaded function in another branch, as in:

from typing import overload
from module import f

if flag():
    @overload
    def a(): ...
else:
    a = f

When checking the local a overload, we resolved the end-of-scope public binding for a to the imported overload set for f. We then tried to render those imported definitions using the current file's AST, which tripped the panic...

We now skip the overload check when the public end-of-scope function does not actually contain the local definition
being checked.

Closes astral-sh/ty#3462.

@charliermarsh charliermarsh added bug Something isn't working ty Multi-file analysis & type inference labels May 14, 2026
@astral-sh-bot

astral-sh-bot Bot commented May 14, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 89.36%. The percentage of expected errors that received a diagnostic held steady at 85.49%. The number of fully passing files held steady at 88/134.

@astral-sh-bot

astral-sh-bot Bot commented May 14, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented May 14, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@charliermarsh charliermarsh force-pushed the charlie/cont branch 2 times, most recently from 9139c0c to bdd38a7 Compare May 14, 2026 22:31
@charliermarsh charliermarsh marked this pull request as ready for review May 14, 2026 23:22
@charliermarsh charliermarsh merged commit 1b96fc1 into main May 14, 2026
58 checks passed
@charliermarsh charliermarsh deleted the charlie/cont branch May 14, 2026 23:22
thejchap pushed a commit to thejchap/ruff that referenced this pull request May 23, 2026
## Summary

Prior to this change, the post-inference overload checks could panic
when a local overload definition was shadowed by an imported overloaded
function in another branch, as in:

```python
from typing import overload
from module import f

if flag():
    @overload
    def a(): ...
else:
    a = f
```

When checking the local `a` overload, we resolved the end-of-scope
public binding for `a` to the imported overload set for `f`. We then
tried to render those imported definitions using the current file's AST,
which tripped the panic...

We now skip the overload check when the public end-of-scope function
does not actually contain the local definition
being checked.

Closes astral-sh/ty#3462.
anishgirianish pushed a commit to anishgirianish/ruff that referenced this pull request May 28, 2026
## Summary

Prior to this change, the post-inference overload checks could panic
when a local overload definition was shadowed by an imported overloaded
function in another branch, as in:

```python
from typing import overload
from module import f

if flag():
    @overload
    def a(): ...
else:
    a = f
```

When checking the local `a` overload, we resolved the end-of-scope
public binding for `a` to the imported overload set for `f`. We then
tried to render those imported definitions using the current file's AST,
which tripped the panic...

We now skip the overload check when the public end-of-scope function
does not actually contain the local definition
being checked.

Closes astral-sh/ty#3462.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: index out of bounds with overload definition in broken conditional

2 participants