-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Ambiguous symbol table names #121914
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
I think a leading dot is a good approach to get a name that doesn't conflict with user-defined names: it always works and it's already what we do in a few other places in the compiler pipeline (e.g., PEP 695 annotation scopes can have a compiler-created local variable called |
Yes and I dislike that way although I couldn't come up with something else... It's a bit too fragile IMO =/ I'm actually happy with both proposals:
|
… genexpr Change the names of the symbol tables for lambda expressions and generator expressions to "<lambda>" and "<genexpr>" respectively to avoid conflicts with user-defined names.
New types for tables will require changing the compiler. Every time we check for FunctionBlock, we should add check for the new types. This can also affect third-party code. Special names would have less impact.
|
Since there may be several symbol tables with the same name, the name cannot be used to identify the symbol table. It is only used as a hint. I would also change the name of the top symbol table to |
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Every symbol table has type and name. The name of the symbol table that corresponds a class or a function is the same as the name of the corresponding class or function. But there are special symbol tables of type function for lambdas and generator expressions (there were also symbol tables for comprehensions, but they are no longer used). For lambdas. the name "lambda" does not conflict with other function names, because it is a reserved word. But for general expressions, the name "genexpr" can conflict with local function "genexpr" (see #119698). It is possible to distinguish the symbol table corresponding to a generator expression by looking in the list of its parameters, but this is not so convenient.
I propose to make the difference more clear:
Either use separate types for lambda and generator expression symbol tables.
Or use names which cannot be confused with any function name:
lambda
. But I do not know good variant for generator expression.gen-expr
.<genexpr>
and<lambda>
..genexpr
.Names of symbol tables of other types like
top
and__annotations__
can also be changed for uniformity and to avoid possible future conflicts.The original issue #119698 was solved in other way, so there is no urge for such change. This is just a wild idea.
Linked PRs
The text was updated successfully, but these errors were encountered: