Skip to content

Fix two crashes in duplicate decorated functions #5427

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

Merged
merged 2 commits into from
Aug 8, 2018

Conversation

ilevkivskyi
Copy link
Member

Fixes #5394
Fixes #5181

The problem is that duplicate decorated functions are parsed as OverloadedFuncDef even if the actual decorator used is not typing.overload. This PR fixes possible crashes related to this. I could imagine there may be some extra spurious errors in some scenarios (in addition to duplicate definition correctly reported by mypy), but at least it should not crash.

@ilevkivskyi ilevkivskyi requested a review from msullivan August 7, 2018 17:58
@ilevkivskyi
Copy link
Member Author

Oops pushed too soon. Will fix the failures in other tests now.

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable!

@@ -427,17 +427,24 @@ class OverloadedFuncDef(FuncBase, SymbolNode, Statement):
"""

items = None # type: List[OverloadPart]
unanalyzed_items = None # type: List[OverloadPart]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't love all these unanalyzed things that aststrip forces upon us. Oh well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried few other solutions, but after few attempts to undo the logic of deleting overloads in second pass, I just went with this, although I don't like this either.

@msullivan msullivan merged commit f637215 into python:master Aug 8, 2018
@ilevkivskyi ilevkivskyi deleted the fix-overload-crash branch August 8, 2018 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants