Fixup Handling of \ in REPL to Prevent Crash

When parsing the string token if a `\` was used it would
unconditionally consume the next character. This would led to a token
with an invalid lenght causing a crash when it was printed. This fixes
that by only consuming the token after the `\` if there is one to
consume.

Fixes #603
This commit is contained in:
Will Speak
2018-10-08 07:35:55 +01:00
parent 744147fd94
commit a4b034f30b
2 changed files with 2 additions and 2 deletions

View File

@ -828,7 +828,7 @@ class Lexer {
if (c == Chars.backslash) {
// TODO: Process specific escapes and validate them.
advance()
if (!isAtEnd) advance()
} else if (c == Chars.percent) {
// Consume the '('.
if (!isAtEnd) advance()

View File

@ -830,7 +830,7 @@ static const char* replModuleSource =
"\n"
" if (c == Chars.backslash) {\n"
" // TODO: Process specific escapes and validate them.\n"
" advance()\n"
" if (!isAtEnd) advance()\n"
" } else if (c == Chars.percent) {\n"
" // Consume the '('.\n"
" if (!isAtEnd) advance()\n"