Skip to content

Commit

Permalink
Fix tryCreateRegexp's error raising code
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Oct 26, 2015
1 parent 09acfbd commit 904ea34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,13 @@ pp.finishOp = function(type, size) {
// Parse a regular expression. Some context-awareness is necessary,
// since a '/' inside a '[]' set does not end the expression.

function tryCreateRegexp(src, flags, throwErrorAt) {
function tryCreateRegexp(src, flags, throwErrorAt, parser) {
try {
return new RegExp(src, flags);
} catch (e) {
if (throwErrorAt !== undefined) {
if (e instanceof SyntaxError) this.raise(throwErrorAt, "Error parsing regular expression: " + e.message)
this.raise(e)
if (e instanceof SyntaxError) parser.raise(throwErrorAt, "Error parsing regular expression: " + e.message)
throw e
}
}
}
Expand Down Expand Up @@ -435,7 +435,7 @@ pp.readRegexp = function() {
// Rhino's regular expression parser is flaky and throws uncatchable exceptions,
// so don't do detection if we are running under Rhino
if (!isRhino) {
tryCreateRegexp(tmp, undefined, start);
tryCreateRegexp(tmp, undefined, start, this);
// Get a regular expression object for this pattern-flag pair, or `null` in
// case the current environment doesn't support the flags it uses.
value = tryCreateRegexp(content, mods)
Expand Down

0 comments on commit 904ea34

Please sign in to comment.