-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Master (0.530-dev) crash on tuple unpacking #4046
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
Comments
This was introduced sometime since Aug 11; we've been using a master revision of mypy from that date up until now without this error, and saw this error when attempting to update to eec6745 today. |
Confirmed as a regression on master. |
I modified the example to make it way shorter. |
Can the OP bisect this to pinpoint to a precise commit/PR? |
I don't know where you get the Aug 11 date from. The same crash happens with v0.4.6, released Nov last year. So I don't think this counts as a regression and that makes the fix less urgent. |
I'm seeing the same thing in attempting to bisect. I think this changed in @ambv 's simplification of the repro case. IOW I believe the root cause is an old bug in mypy, and a typeshed change since Aug 11 triggered the bug on our actual code using |
The original longer repro case:
bisects to #3967. Before that it typechecks clean. Working on bisecting it within typeshed. |
Not surprisingly, the recent regression bisects to python/typeshed#1550 |
Thanks for confirming my hunch that the simplified repro was worth a separate message rather than editing the OP. :-) So it seems that the actual bug is old and the improved Maybe @JukkaL or @ilevkivskyi have a fresh insight when they get up. |
I noticed that this does not happen for list types, which led me to believe it is part of the special tuple checking code. Stepping through the code, we end up here. Essentially, we usually give the rvalue type to definitions, which is the correct thing to do. However, when checking nested lvalue tuple types, we check recursively, so the new definition types don't have an rvalue to inherit, causing their type to be |
Yes, this is related to #3966, I actually already have a fix on my last strict optional branch. I will add a test and make a PR now. |
Hm, although the crashes are fixed on my branch, the revealed types of |
Fixes #4046 The root cause for the crash is that None was put in TupleType items if the corresponding lvalue is a definition. Then the crash happens when this TupleType is used as a context for rvalue type inference. The solution is to put UninhabitedType in such cases, so that inference will fall back on using argument types instead.
@gvanrossum We don't need it cherry-picked into the release because we don't use releases. Thanks for the quick fix and merge to master! |
Repro:
produces:
The text was updated successfully, but these errors were encountered: