Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[[FIX]] Improve tokenization of RegExp literals (#3471)
  • Loading branch information
jugglinmike committed May 5, 2020
1 parent 8deec6f commit f786002
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lex.js
Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/test262/expectations.txt
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/parser.js
Expand Up @@ -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();
};

Expand Down

0 comments on commit f786002

Please sign in to comment.