-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Add SyntaxError hint for incorrectly using C "//" or "/*...*/" to comment #134002
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
What to do with comments like
Why? I wan't this: >>> 1 // 1j
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
1 // 1j
~~^^~~~
TypeError: unsupported operand type(s) for //: 'int' and 'complex'
I don't get it. Could you please explain what exactly this means? |
Ok. The message is "Did you mean '#'" if is "//" or "Did you mean ' ''' ' or ' """ '" if "/*", like others. |
Why should be at the first of the line? Because if at the centre, it is complex. |
I don't find it helpful. Last chance. I entered "1 // 1j" in CPython repl. How will look traceback with your proposal? Currently we have (repeat):
|
What does the conditions means is that if the SyntaxError raised by "//", it needs to check, if the "//" is not the beginning of the line of the code, the message shouldn't be show. |
The "//" is not at the beginning of the code, so it doesn't satify with the condition. I have explained. |
Sorry, you don't. One of you examples in the description looks: #TypeError(don't need)
def one_or_two():
a = random.randrange(1,2)
print(a) // 1 or 2 Do you mean we need to replace TypeError here? Could you please be more precise and provide exact suggestions to all your examples? How tracebacks will look? If your proposal is raising a SyntaxError with a different message iff the |
It just show the complex of the conditions that "//" at the centre of the line. So what I mean is that to escape from those conditions, only when "//" at the beginning of the line. |
I understand the intent, but I don't find this to be overly useful. The code you included in your examples already raises a SyntaxError, I think a competent developer should be able to recognize that they messed up the comment syntax based solely on the current SyntaxError. This is just my opinion, though. |
There is a communication problem here; let's be gentile with that. The proposal (formulated to be possible) is that if a line beginning with Problems with the proposal:
|
This is invalid for
Though, point 3) holds in this case. |
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
Sometimes another programmer may make the mistake that using "//" or "/**/" to comment, especially cross-language projects.
In my option, showing the message need to satisfy the following comditions:
If the Exception raised by "//":
1: must at the beginning of the line.
2: the last line of the code cannot be end with ""
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: