-
Notifications
You must be signed in to change notification settings - Fork 293
Improve Step 5 of overload call evaluation. #2250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rchen152
wants to merge
12
commits into
python:main
Choose a base branch
from
rchen152:overload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
47637e8
Improve Step 5 of overload call evaluation.
rchen152 045a46b
Merge branch 'main' into overload
rchen152 fbb847e
Typo fix
rchen152 89e6130
Remove unsafe overlap in overload example.
rchen152 4e7c475
Clarifications
rchen152 891f7ae
Clarification: unpacked arguments
rchen152 137e3fc
Consistent style
rchen152 88a046c
Merge branch 'main' into overload
rchen152 bef8d53
Remove redundant paragraph.
rchen152 3e07524
More test.
rchen152 866613b
Merge branch 'main' into overload
rchen152 7d7a176
Only type vars scoped to the current function should be replaced.
rchen152 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Clarifications
* "remaining" overloads => "candidate" overloads * moar tests
- Loading branch information
commit 4e7c475312291159dd0cc6090406a8e94c1b956c
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,15 +268,15 @@ If so, eliminate overloads that do not have a variadic parameter. | |
| Step 5 | ||
| ~~~~~~ | ||
|
|
||
| For each of the remaining overloads, determine whether all arguments satisfy at | ||
| For each of the candidate overloads, determine whether all arguments satisfy at | ||
| least one of the following conditions: | ||
|
|
||
| - All possible :term:`materializations <materialize>` of the argument's type are | ||
| assignable to the corresponding parameter type, or | ||
| - The parameter types corresponding to this argument in all of the remaining overloads | ||
| - The parameter types corresponding to this argument in all of the candidate overloads | ||
| are :term:`equivalent`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is correct but there's some subtlety in the wording that we should cover in the test cases:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great points, thanks!
|
||
|
|
||
| If so, eliminate all of the subsequent remaining overloads. | ||
| If so, eliminate all of the subsequent candidate overloads. | ||
|
|
||
| Consider the following examples:: | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented in ty the additional rule that a candidate overload return type is only considered "most general" if it is also assignable to all matched overloads. The only expectation in these conformance tests that changes as a result is this one; it reverts back to
Unknown/Any.If you are happy with the
intresult in this case for pyrefly, I can discuss with the ty team, but I think we might prefer if the conformance suite gave leeway for a type checker to give a more gradual result here. (We might prefer a type that relies on intersections.)