diff --git a/lib/repl.js b/lib/repl.js index fcb9c1f32fc..6ebcdc1814b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -273,6 +273,7 @@ function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) { return e && e.match(/^SyntaxError/) && // RegExp syntax error !e.match(/^SyntaxError: Invalid regular expression/) && + !e.match(/^SyntaxError: Invalid flags supplied to RegExp constructor/) && // JSON.parse() error !(e.match(/^SyntaxError: Unexpected token .*\n/) && e.match(/\n at Object.parse \(native\)\n/)); diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index 7360dfd998a..ff6b5f98ecc 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -130,6 +130,10 @@ function error_test() { // should throw { client: client_unix, send: '/(/;', expect: /^SyntaxError: Invalid regular expression\:/ }, + // invalid RegExp modifiers are a special case of syntax error, + // should throw (GH-4012) + { client: client_unix, send: 'new RegExp("foo", "wrong modifier");', + expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ }, // Named functions can be used: { client: client_unix, send: 'function blah() { return 1; }', expect: prompt_unix },