Skip to content
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

Merged
merged 1 commit into from
Mar 26, 2019

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Mar 21, 2019

Previously, we produced errors like this:

gap> function() 123; end;
Syntax error: 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.

Resolves #1117

@fingolfin fingolfin added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: kernel labels Mar 21, 2019
@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.145% when pulling a086dc1 on fingolfin:mh/nicer-errors into b4836bb on gap-system:master.

@@ -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
Copy link
Member Author

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)

Suggested change
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?

Copy link
Contributor

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)

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now updated

Copy link
Member Author

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

@wucas wucas added the gapdays2019-spring Issues and PRs that arose at https://www.gapdays.de/gapdays2019-spring label Mar 22, 2019
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.
@codecov
Copy link

codecov bot commented Mar 25, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@6424be9). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #3372   +/-   ##
=========================================
  Coverage          ?   85.17%           
=========================================
  Files             ?      697           
  Lines             ?   344559           
  Branches          ?        0           
=========================================
  Hits              ?   293487           
  Misses            ?    51072           
  Partials          ?        0
Impacted Files Coverage Δ
src/read.c 94.4% <100%> (ø)

@fingolfin
Copy link
Member Author

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.).

@fingolfin fingolfin merged commit bf9bec2 into gap-system:master Mar 26, 2019
@fingolfin fingolfin deleted the mh/nicer-errors branch March 26, 2019 22:27
@fingolfin fingolfin changed the title Make some interpreter / reader errors a bit nicer Make some interpreter errors a bit nicer Apr 5, 2019
@fingolfin fingolfin added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Apr 15, 2019
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.11.0 milestone Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2019-spring Issues and PRs that arose at https://www.gapdays.de/gapdays2019-spring kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhelpful error message (?)
7 participants