Skip to content

Commit

Permalink
Make sure that syntax error messages during EvalString are displayed …
Browse files Browse the repository at this point in the history
…correctly
  • Loading branch information
zickgraf authored and fingolfin committed Dec 7, 2022
1 parent 31e795b commit 391c4dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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.

0 comments on commit 391c4dd

Please sign in to comment.