Skip to content

Commit

Permalink
repl: allow multiline function call
Browse files Browse the repository at this point in the history
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: nodejs#3823
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
Zirak authored and stefanmb committed Feb 23, 2016
1 parent d7a7fc9 commit c36d73d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit c36d73d

Please sign in to comment.