Skip to content

Commit

Permalink
[[FIX]] Allow regex inside template literal
Browse files Browse the repository at this point in the history
Fixes gh-2791
  • Loading branch information
nicolo-ribaudo authored and jugglinmike committed Jan 16, 2016
1 parent caa30e6 commit 5dd9c90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lex.js
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,10 @@ Lexer.prototype = {
}
}

if (type === "(template)" || type === "(template middle)") {
this.prereg = true;
}

if (!obj) {
obj = Object.create(state.syntax[type]);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ exports.regexp = function (test) {
run.test(code, {esnext: true});
run.test(code, {moz: true});

TestRun(test).test("var a = `${/./}${/./}`;", { esversion: 6 });


// Pre Regular Expression Punctuation
// (See: token method, create function in lex.js)
Expand Down

0 comments on commit 5dd9c90

Please sign in to comment.