From 11aad46078707daf8ed64d12c5441406b144d478 Mon Sep 17 00:00:00 2001 From: Rob Colburn Date: Tue, 24 Jun 2014 12:53:07 -0700 Subject: [PATCH] Throw descriptive error for Invalid RegExp Throws up descriptive error when parsing an invalid regular expression "test".match(/test/i || /test2/i); --- lib/output.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index b9637929..f4ec36b1 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1153,7 +1153,12 @@ function OutputStream(options) { }; DEFPRINT(AST_RegExp, function(self, output){ - var str = self.getValue().toString(); + var str = self.getValue() + try { + str = str.toString(); + } catch (e) { + throw new Error('Cannot evaluate RegExp [' + self.start.file + ':' + self.start.line + ',' + self.start.col + ']'); + } if (output.option("ascii_only")) { str = output.to_ascii(str); } else if (output.option("unescape_regexps")) {