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
Refactor error messages in symtable.c #72287
Comments
Patch with added comment and a minor refactoring to error messages in symtable.c Now the error message is simply always overwritten by any more "severe" SyntaxError found in the same block. |
Please rewrite the patch to use if / else if / else, e.g. if (cur & (DEF_LOCAL | USE | DEF_ANNOT)) {
...
if (cur & USE) {
msg = GLOBAL_AFTER_USE;
} else if (cur & DEF_LOCAL) {
msg = GLOBAL_AFTER_ASSIGN;
} else { /* DEF_ANNOT */
msg = GLOBAL_ANNOT;
}
...
} |
Here is the patch for 3.6 with requested changes. While playing with this a bit more, I discovered that the error message in this case (if no value is actually assigned): def f():
x: int
global x could be misleading. Therefore I changed the order of DEF_LOCAL and DEF_ANNOT to get a more clear error message for such cases (this does not spoil error messages in other cases). |
New changeset 966b57281536 by Christian Heimes in branch '3.6': New changeset a953112116ac by Christian Heimes in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: