-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Error range of "duplicate argument" SyntaxErrors is too big #90200
Comments
The error range for the "duplicate argument in function definition" SyntaxError is too large: $ cat x.py
def f(a, b, c, d, e, f, g, a): pass
$ python x.py
File "/home/cfbolz/projects/cpython/x.py", line 1
def f(a, b, c, d, e, f, g, a): pass
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: duplicate argument 'a' in function definition I would expect only the second 'a' to be underlined. I can try to fix this. |
Thanks for the catch Carl!
Awesome, I will wait for the PR! |
let's see whether I promised too much, I don't know CPython's symtable.c too well yet ;-). Will shout for help when I get stuck. Anyway, here is a related bug, coming from the same symtable function symtable_add_def_helper, also with an imprecise error location: $ cat x.py
{i for i in range(5)
if (j := 0)
for j in range(5)}
$ ./python x.py
File "/home/cfbolz/projects/cpython/x.py", line 1
{i for i in range(5)
^^^^^^^^^^^^^^^^^^^^
SyntaxError: comprehension inner loop cannot rebind assignment expression target 'j' |
Don't worry, turns out it was a bit messier than I thought, so I prepared the PR. If you have some time, it would be great if you can take a quick look. |
Oh no, I was about to open mine ;-) Basically equivalent, but I fixed the second bug too (would be very easy to add to yours) |
ah, confused, seems you fixed them both too. will take a closer look! |
Sorry, Carl, I apologize. I hope it was not too disruptive to do the work. I was taking a look and I felt bad that the issue was probably messier than I thought and I didn't want you to have to iterate many times :( Thanks a lot for helping review the PR and for pointing out the extra cases!! |
Oh, don't worry, it's all good! It got fixed and I learned something. |
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: