Skip to content

Don't simplify out ErasedType from unions during type inference #8095

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
Dec 5, 2019

Conversation

ilevkivskyi
Copy link
Member

Fixes #8093

The fix is kind of simple, we really need to keep all ErasedTypes intact to preserve the existing type inference logic, but it is also long because I need to thread the flag down like dozen function calls.

The issue itself btw highlight how fragile is current type inference logic (note that expand_type() implicitly calls make_simplified_union() too, but I think that one doesn't need to be updated because it shouldn't be called with any erased components).

@ilevkivskyi ilevkivskyi requested a review from JukkaL December 5, 2019 19:17
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks good, just one comment. I agree that the type inference implementation is pretty fragile and unprincipled. Maybe we can do something about it next year.


x: Optional[str]

pagelets = filter(None, [x])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Test that the type of pagelets is List[str]?

@ilevkivskyi ilevkivskyi merged commit 5680f5c into python:master Dec 5, 2019
@ilevkivskyi ilevkivskyi deleted the fix-the-fix branch December 5, 2019 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type inference regression involving filter(None, ...)
2 participants