-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Changed error message for end-of-line colons #34756
Conversation
As recently shown, error message suggesting the wrong cause can be very confusing for people that hit it for other reasons. Having guess work in the error message is fine but I don't believe having EOL |
I did a google search for exact matches of the error message and got the following breakdown for 19 results:
Based on this breakdown, I removed the parts of the error message talking about if/while/for statements but kept the part re. function definitions. I think that this change, at least for the time being, would not majorly confuse people debugging ternary operator errors. |
While it's nice that you did the research by searching for the error message, the result, unfortunately doesn't mean anything. It's by construction biased against people whose problem is solved by the current error message. FWIW, I think mentioning while/if/for is fine, removing them makes it worse. |
You're right. I'll try to change this so that the message only comes up in more specific cases. |
Fwiw, I don't think you need to be too specific. Just end of line should be good enough and from a quick look at the code that should not be hard.... |
Alright, I changed the error message from
to
in the two places where it's relevant. |
I do think this is a strict improvement. You could probably also split the conditon and give your python related error message if the first condition is true. |
src/julia-parser.scm
Outdated
@@ -1220,7 +1220,7 @@ | |||
(take-token s) | |||
(if (or (eqv? (peek-token s) #\newline) | |||
(ts:space? s)) ;; uses side effect of previous peek-token | |||
(error "space not allowed after \":\" used for quoting")) | |||
(error "space or newline not allowed after \":\" used for quoting")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(error "space or newline not allowed after \":\" used for quoting")) | |
(cond ((eqv? (peek-token s) #\newline) | |
(error "newline not allowed after \":\" used for quoting")) | |
((ts:space? s) ;; uses side effect of previous peek-token | |
(error "whitespace not allowed after \":\" used for quoting")) | |
((else |
The expression ``` function test_function(inputs): ... end ``` currently gives the following syntax error ``` ERROR: syntax: space not allowed after ":" used for quoting ``` This can be a bit confusing for users who do not know about quoting and do not intend it to be used as such. Since this kind of mistake is common for users coming from Python, try to give an improved error message.
119be8c
to
41c4030
Compare
Rebased and applied @vtjnash's suggestion to both instances. |
…Lang#34756) The expression ``` function test_function(inputs): ... end ``` currently gives the following syntax error ``` ERROR: syntax: space not allowed after ":" used for quoting ``` This can be a bit confusing for users who do not know about quoting and do not intend it to be used as such. Since this kind of mistake is common for users coming from Python, try to give an improved error message.
The expression ``` function test_function(inputs): ... end ``` currently gives the following syntax error ``` ERROR: syntax: space not allowed after ":" used for quoting ``` This can be a bit confusing for users who do not know about quoting and do not intend it to be used as such. Since this kind of mistake is common for users coming from Python, try to give an improved error message.
I'm a Python user who's just starting to learn Julia, and I was playing around with function definitions and wrote a function with the following syntax:
I then got the following error message:
ERROR: syntax: space not allowed after ":" used for quoting
I was confused because I wasn't aware yet that colons were used for quoting, and ended up trying to search for a space character in my code (after all, I had a newline - not a space - after the colon). Wasted quite a bit of time trying to fix it.
This PR just changes the error message to the following, meant to be nudge Python users in the right direction:
ERROR: syntax: space not allowed after ":" used for quoting. (Did you put ":" after a function/if/while/for statement?)