Repository navigation
fix: flag overload signatures not immediately followed by implementation - #5310
Closed
Aayushyaash wants to merge 2 commits into
Closed
Aayushyaash wants to merge 2 commits into
Aayushyaash wants to merge 2 commits into
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D126658648. (Because this pull request was imported automatically, there will not be any future comments.) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
Hmm. This had a merge conflict which I tried to resolve (it was just tests). But now test are failing, I suspect it just needs a rebase(?) Thanks for working on this! |
Aayushyaash
force-pushed
the
fix-overload-contiguous-check
branch
from
October 22, 2026 20:03
eaa1ddd to
121b771
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Contributor
Author
|
Rebased cleanly onto the latest |
stroxler
approved these changes
Oct 23, 2026
stroxler
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Contributor
|
This pull request has been merged in 6d51669. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PEP 484 and the Python Typing Specification require
@overloadsignatures to appear consecutively, immediately followed by their implementation. Intervening statements, such as other function definitions, variable assignments, or expressions, break this sequence and should be reported.Previously, Pyrefly linked overload predecessors by lexical identifier within the scope (
flow.get_value(name)). Because intervening statements updated only their own entries inFlow, the previous overload entry remained available, allowing Pyrefly to incorrectly link overloads across those statements without reporting an error.This PR fixes the issue by:
last_func_def: Option<(Name, bool)>inFlowand resetting it when processing non-function statements instmt_impl.create_function_indexwhen linking an overload to its predecessor, recording the result inBindingDecoratedFunction.is_contiguous.InvalidOverloaddiagnostic insolve_function_bindingwhenfunction_binding.is_contiguousis false.Fixes #5212
Test Plan
Added unit tests in
pyrefly/lib/test/overload.rscovering:@overloadsignatures.Validation