From 98907c716b48a7e460cb5b7283d4a12cbcd15e66 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 7e6533d29a..37607ef0c9 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 aa5d8d2680..539878a947 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 },