-
Notifications
You must be signed in to change notification settings - Fork 160
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
Make some interpreter errors a bit nicer #3372
Conversation
tst/testbugfix/2012-09-06-t00253.tst
Outdated
@@ -13,6 +13,6 @@ gap> Read(s); | |||
Syntax error: ) expected in stream:4 | |||
v := rec(a := [];); | |||
^ | |||
Syntax error: end expected in stream:5 | |||
Syntax error: inside a function, statement or 'end' expected in stream:5 |
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.
reading this again today, perhaps a semicolon
would make this a bit clearer, as here (note that the "expected" is added automatically at the end, so we have to contort ourselves a bit to fit the sentence structure in there)
Syntax error: inside a function, statement or 'end' expected in stream:5 | |
Syntax error: inside a function; statement or 'end' expected in stream:5 |
Thoughts?
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.
While ; might be more mathematically correct, I feel that in code I always read it as "end of statement".
How about "Syntax error while parsing a function: statement or 'end' expected" (so push the new stuff before the semicolon)
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.
The "Syntax error:" prefix and "expected" suffix are fixed, I can only fill in stuff between them, so the best I can offer w/o deeper changes is this:
Syntax error: while parsing a function: statement or 'end' expected
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.
What do you think about either of these options, which break the error into two sentences with a full stop? (It also adds commas around the "or" option; the difference between the two options is the presence of the word "was")
Syntax error: inside a function. A statement, or 'end', was expected in stream:5
Syntax error: inside a function. A statement, or 'end', expected in stream:5
However I don't feel particularly strongly about any of the suggestions put forth in this PR/discussion, so I don't really mind.
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.
Now updated
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.
@wilfwilson sorry, I did not actually see your comment before I updated this PR, i.e., I did not deliberately ignore it! Your variant is also fine by me. I'll think about it again tomorrow, after some sleep. Perhaps others have an opinion, too
Previously, we produced errors like this: gap> function() 123; end; Syntax error: inside a function, statement or 'end' expected function() 123; end; ^^^ This now is slightly more helpful and reads as follows. gap> function() 123; end; Syntax error: while parsing a function: statement or 'end' expected function() 123; end; ^^^ Similar adjustments are made for loops, atomic blocks and if statements.
a086dc1
to
7d6b969
Compare
Codecov Report
@@ Coverage Diff @@
## master #3372 +/- ##
=========================================
Coverage ? 85.17%
=========================================
Files ? 697
Lines ? 344559
Branches ? 0
=========================================
Hits ? 293487
Misses ? 51072
Partials ? 0
|
I think I'll just merge this as is: it is an improvement over the current status quo, and a truly better message will require more flexibility in the code which generates those messages (to not force the trailing "expected" etc.). |
Previously, we produced errors like this:
This now is slightly more helpful and reads as follows.
Similar adjustments are made for loops, atomic blocks and if statements.
Resolves #1117