Skip to content
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

Make join of recursive types more robust #13808

Merged
merged 1 commit into from
Oct 8, 2022

Conversation

ilevkivskyi
Copy link
Member

Fixes #13795

Calculating tuple fallbacks on the fly creates a cycle between joins and subtyping. Although IMO this is conceptually not a right thing, it is hard to get rid of (unless we want to use unions in the fallbacks, cc @JukkaL). So instead I re-worked how join_types() works w.r.t. get_proper_type(), essentially it now follows the golden rule "Always pass on the original type if possible".

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@@ -443,7 +456,7 @@ def visit_tuple_type(self, t: TupleType) -> ProperType:
if self.s.length() == t.length():
items: list[Type] = []
for i in range(t.length()):
items.append(self.join(t.items[i], self.s.items[i]))
items.append(join_types(t.items[i], self.s.items[i]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be forwarding self.instance_joiner?

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW it didn't, so it should be a matter of a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also I am not sure it actually should.

@hauntsaninja hauntsaninja merged commit dbe9a88 into python:master Oct 8, 2022
@ilevkivskyi ilevkivskyi deleted the fix-rec-tuple branch October 8, 2022 21:42
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.

Core dumped when using JSON.loads with a recursive type
2 participants