[JS Parser] Fix bug with decoding escape sequences

This commit is contained in:
Jarred Sumner
2022-03-07 00:31:10 -08:00
parent 5ee063f6b2
commit 2cc265361d

View File

@@ -461,7 +461,7 @@ fn NewLexer_(
try lexer.syntaxError();
}
const hex_start = iter.i - width - width2 - width3;
const hex_start = (iter.i + start) - width - width2 - width3;
var is_first = true;
var is_out_of_range = false;
variableLength: while (true) {
@@ -480,13 +480,13 @@ fn NewLexer_(
},
'}' => {
if (is_first) {
lexer.end = start + iter.i - width3;
lexer.end = (start + iter.i) -| width3;
return lexer.syntaxError();
}
break :variableLength;
},
else => {
lexer.end = start + iter.i - width3;
lexer.end = (start + iter.i) -| width3;
return lexer.syntaxError();
},
}
@@ -501,7 +501,7 @@ fn NewLexer_(
if (is_out_of_range) {
try lexer.addRangeError(
.{ .loc = .{ .start = @intCast(i32, start + hex_start) }, .len = @intCast(i32, (iter.i - hex_start)) },
.{ .loc = .{ .start = @intCast(i32, start + hex_start) }, .len = @intCast(i32, ((iter.i + start) - hex_start)) },
"Unicode escape sequence is out of range",
.{},
true,