Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[[FIX]] Improve tokenization of RegExp literals #3471

Merged
merged 1 commit into from May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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