-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Type variable not substituted in a nested function within a generic function #1323
Comments
Wow, this may also explain some problems with decorators that I've seen.
|
The type I tried rewriting function references in |
Sounds reasonable. The current approach was designed for a compiler and
|
I guess the tradeoff is that we'd need to find all places in the type
|
These were exactly my thoughts as well. How does this sound as a plan?
I implemented most of this in rwbarton@2f94f22; it raises errors on the program in this issue ( With this kind of linting in place, we should be able to implement the alternate approach without missing anywhere that we need to substitute a type. |
Hmm, it turns out that copying the syntax tree of the function being type checked is important in cases like this one from the test suite.
If we don't copy the syntax tree of |
Ah yes, I didn't remember about that. Do you think that we should go back to fixing |
Moved this to 0.4.x. |
Yeah, I think so. I submitted a PR. |
Mypy reports a bogus error for the following program (reported by Alex Allain):
I suspect that mypy doesn't substitute T in the nested function when type checking the outer function. Generalizing substitution to nested functions might be enough to fix this.
The text was updated successfully, but these errors were encountered: