-
-
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
Clean-up type variable scope and binding #4814
Comments
Another related comment here is that we have a bit too many "things" related to type variables (in addition to
|
Probably it makes sense to clean up (or at least document) various things related to type variable scopes while we are working on the new semantic analyzer. I just discovered an inconsistency in new analyzer, it was using full type variable name where short one was expected. Without documentation, such errors are easy to make. |
In the spirit of #4814 (comment) I'm not sure what the distinction between TypeVarDef and TypeVarType was (note that there's also TypeVarExpr, whose purpose is clear to me). In practice, it seems it boiled down to: a) TypeVarDef has a different __repr__, that's not user facing but was used in tests, b) in two places, we used the construction of a TypeVarType from a TypeVarDef as an opportunity to change the line number. I ran into this because: a) I was considering whether to create a corresponding ParamSpecDef and ParamSpecType b) I was trying to fix an issue with applytype sometimes swallowing generics, which to fix I needed TypeVarType to have access to its TypeVarDef. I was unable to find a reason for TypeVarType to not just be the TypeVarDef and here we are. Co-authored-by: hauntsaninja <>
FWIW I more happy now with how type variables work (e.g. we use namespaces everywhere). There still may be bugs, I think |
Currently the code around type variable binding in functions is a bit unclear and does some strange things like binding typer variables before function type is analyzed and depending on
TypeVarQuery
returning short (unqualified) names.The text was updated successfully, but these errors were encountered: