From f786002a14b89216909533355aa53411f43f6277 Mon Sep 17 00:00:00 2001 From: jugglinmike Date: Tue, 5 May 2020 13:32:57 -0400 Subject: [PATCH] [[FIX]] Improve tokenization of RegExp literals (#3471) --- src/lex.js | 3 ++- tests/test262/expectations.txt | 2 -- tests/unit/parser.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lex.js b/src/lex.js index 7626e252cb..c5431649a1 100644 --- a/src/lex.js +++ b/src/lex.js @@ -1987,7 +1987,8 @@ Lexer.prototype = { if (type === "(identifier)") { if (value === "return" || value === "case" || value === "yield" || value === "typeof" || value === "instanceof" || value === "void" || - value === "await") { + value === "await" || value === "new" || value === "delete" || + value === "default" || value === "extends") { this.prereg = true; } diff --git a/tests/test262/expectations.txt b/tests/test262/expectations.txt index 468e0aab2d..183b9ba969 100644 --- a/tests/test262/expectations.txt +++ b/tests/test262/expectations.txt @@ -117,8 +117,6 @@ test/annexB/language/expressions/object/__proto__-duplicate.js(strict mode) test/annexB/language/statements/for-in/nonstrict-initializer.js(default) test/built-ins/Function/prototype/toString/unicode.js(default) test/built-ins/Function/prototype/toString/unicode.js(strict mode) -test/built-ins/RegExp/S15.10.7_A2_T1.js(default) -test/built-ins/RegExp/S15.10.7_A2_T1.js(strict mode) test/language/asi/S7.9.2_A1_T2.js(default) test/language/asi/S7.9_A1.js(default) test/language/asi/S7.9_A1.js(strict mode) diff --git a/tests/unit/parser.js b/tests/unit/parser.js index 8e99695bbc..3c37cdf16c 100644 --- a/tests/unit/parser.js +++ b/tests/unit/parser.js @@ -761,6 +761,21 @@ exports.regexp.basic = function (test) { "void /\\09/;" ]); + TestRun(test, "following `new`") + .addError(1, 5, "Bad constructor.") + .addError(1, 5, "Missing '()' invoking a constructor.") + .test("new /./;"); + + TestRun(test, "following `delete`") + .addError(1, 11, "Variables should not be deleted.") + .test("delete /./;"); + + TestRun(test, "following `extends`") + .test("class R extends /./ {}", {esversion: 6}); + + TestRun(test, "following `default`") + .test("export default /./;", {esversion: 6, module: true}); + test.done(); };