Implement Overload decorator in pure python#166
Merged
certik merged 3 commits intolcompilers:mainfrom Feb 24, 2022
Merged
Conversation
Collaborator
Smit-create
commented
Feb 24, 2022
- References: Figure out how to handle generic functions #141, Figure out how to handle generic functions #141 (comment)
certik
reviewed
Feb 24, 2022
| # This might fail for the cases when arguments don't match | ||
| ann_dict = getcallargs(func, *args, **kwargs) | ||
| except TypeError: | ||
| continue |
Contributor
There was a problem hiding this comment.
If the arguments don't match, shouldn't we rather raise an exception that the arguments don't match?
Collaborator
Author
There was a problem hiding this comment.
Suppose, the list contains two functions foo(a) and foo(a, b), then, foo(1, 2) will raise an error if we use getcallargs on the first function.
Contributor
There was a problem hiding this comment.
Right. We should determine which of the overloads contains two integer arguments in this case. And just call that.
Collaborator
Author
There was a problem hiding this comment.
Yes, that's right!
certik
approved these changes
Feb 24, 2022
Contributor
certik
left a comment
There was a problem hiding this comment.
I think that this looks good and we can merge it. I left a comment above about what happens if the arguments don't match, but I think it can be fixed later.
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.