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 sure that syntax error messages during EvalString are displayed correctly #5246

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/string.gi
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ InstallGlobalFunction("EvalString", function( s )
local a, f, res;
a := "_EVALSTRINGTMP:=";
Append(a, s);
Add(a, ';');
# The code handling syntax error messages breaks if the semicolon is the
# last character in the input stream. We thus add a line break just as one
# would by pressing the <RETURN> key while in the REPL.
Append(a, ";\n");
Unbind(_EVALSTRINGTMP);
f := InputTextString(a);
Read(f);
Expand Down
8 changes: 8 additions & 0 deletions tst/testbugfix/2022-12-06-EvalString-syntax-error.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# make sure that syntax error messages during EvalString are displayed correctly
# See https://github.com/gap-system/gap/issues/5242
gap> EvalString( "(1" );
Syntax error: ) expected in stream:1
_EVALSTRINGTMP:=(1;
^
Error, Could not evaluate string.