Skip to content

Commit

Permalink
[[FIX]] Tolerate RegExp as void operand
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike authored and rwaldron committed Nov 28, 2017
1 parent d03662c commit 3f920b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lex.js
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ Lexer.prototype = {

if (type === "(identifier)") {
if (value === "return" || value === "case" || value === "yield" ||
value === "typeof" || value === "instanceof") {
value === "typeof" || value === "instanceof" || value === "void") {
this.prereg = true;
}

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ exports.regexp = function (test) {
"var x = w - /s/;",
"var y = typeof /[a-z]/;", // GH-657
"var z = /a/ instanceof /a/.constructor;", // GH-2773
"void /./;",
"var v = /dsdg;"
];

Expand All @@ -576,8 +577,8 @@ exports.regexp = function (test) {
.addError(17, 9, "Invalid regular expression.")
.addError(20, 9, "Invalid regular expression.")
.addError(21, 9, "Invalid regular expression.")
.addError(28, 9, "Unclosed regular expression.")
.addError(28, 9, "Unrecoverable syntax error. (100% scanned).");
.addError(29, 9, "Unclosed regular expression.")
.addError(29, 9, "Unrecoverable syntax error. (100% scanned).");

run.test(code, {es3: true});
run.test(code, {}); // es5
Expand Down

0 comments on commit 3f920b5

Please sign in to comment.