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.
  • Loading branch information
Zirak committed Feb 16, 2016
1 parent 8b57b31 commit 56a433b
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 @@ -1126,7 +1126,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 @@ -180,6 +180,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 56a433b

Please sign in to comment.