Better parsing errors: indicate position with a caret #33735
Labels
domain:error messages
Better, more actionable error messages
parser
Language parsing and surface syntax
I have some new or newish programmers and am trying to pay attention to their roadblocks in learning Julia, so I may occasionally file issues which don't look like my usual fare.
Suppose you try to define a variable using a name that starts with a number:
A new programmer might wonder, why does this talk about a "function argument name"? I haven't called any functions (or so I thought).
Python is not great at this, but the differences are interesting:
"invalid syntax" isn't very helpful, but python partly makes up for this with the caret syntax showing the specific place in the line that causes the trouble. (In this case, disambiguating which 2 is the problematic one.)
C (gcc) is much better, though still lacks the key hint that variable names should not start with a number:
Matlab isn't perfect either, but it goes out of its way to be helpful:
(To clarify, that
x = 22
is queued up on the REPL.)To me, the biggest takeaway is that most other languages have decided that a caret mark is a crucial component of the parser's error-reporting.
The text was updated successfully, but these errors were encountered: