Fix CRLF handling in line continuation escapes (#1564)

This commit is contained in:
Kushal Pisavadia
2026-04-29 21:53:55 +01:00
committed by GitHub
parent 39c01c24ba
commit d3a3a14aaa
2 changed files with 58 additions and 2 deletions
@@ -461,11 +461,17 @@ public final class Lexer {
}
case 'u' -> lexUnicodeEscape();
case '\n' -> Token.STRING_ESCAPE_CONTINUATION;
case '\r' -> {
if (lookahead == '\n') {
nextChar();
}
yield Token.STRING_ESCAPE_CONTINUATION;
}
case ' ', '\t' -> {
var c = cursor;
var next = nextChar();
while (next == ' ' || next == '\t') next = nextChar();
if (next == '\n')
if (next == '\n' || next == '\r')
throw lexError(
ErrorMessages.create("invalidLineContinuationEscapeSequenceWhitespace"),
c - 2,