From a06066ca3180c86fa93b4f220867c1fd0c54f678 Mon Sep 17 00:00:00 2001 From: Zirak Date: Sat, 14 Nov 2015 10:59:22 +0000 Subject: [PATCH] repl: allow multiline function call Currently, the repl allows multiline function declarations, strings, and all sorts of niceties by catching the SyntaxErrors they issue and ignoring them. However, the SyntaxError raised by multiline function calls was not caught. This commit adds to the whitelist. PR-URL: https://github.com/nodejs/node/pull/3823 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- lib/repl.js | 5 ++++- test/parallel/test-repl.js | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index 5077925968bae7..cc6191661f909f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1150,7 +1150,10 @@ function isRecoverableError(e, self) { self._inTemplateLiteral = true; return true; } - return /^(Unexpected end of input|Unexpected token)/.test(message); + + return message.startsWith('Unexpected end of input') || + message.startsWith('Unexpected token') || + message.startsWith('missing ) after argument list'); } return false; } diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index aa5d8d26809570..539878a9475585 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -185,6 +185,13 @@ function error_test() { expect: prompt_multiline }, { client: client_unix, send: '})()', expect: '1' }, + // Multiline function call + { client: client_unix, send: 'function f(){}; f(f(1,', + expect: prompt_multiline }, + { client: client_unix, send: '2)', + expect: prompt_multiline }, + { client: client_unix, send: ')', + expect: 'undefined\n' + prompt_unix }, // npm prompt error message { client: client_unix, send: 'npm install foobar', expect: expect_npm },