mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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 <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
committed by
Sakthipriyan Vairamani
parent
57891c3cfe
commit
a06066ca31
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user