Skip to content

Commit

Permalink
repl: fix eval return value
Browse files Browse the repository at this point in the history
In case no error has occurred during the evaluation of some code,
`undefined` has been returned in some cases as error argument instead
of `null`. This is fixed by this patch.

PR-URL: #25731
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
BridgeAR authored and addaleax committed Feb 6, 2019
1 parent e66cb58 commit 5aaeb01
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ function REPLServer(prompt,
}

function defaultEval(code, context, file, cb) {
var err, result, script, wrappedErr;
var wrappedCmd = false;
var awaitPromise = false;
var input = code;
let result, script, wrappedErr;
let err = null;
let wrappedCmd = false;
let awaitPromise = false;
const input = code;

if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) {
// It's confusing for `{ a : 1 }` to be interpreted as a block
Expand Down Expand Up @@ -363,7 +364,7 @@ function REPLServer(prompt,
}

promise.then((result) => {
finishExecution(undefined, result);
finishExecution(null, result);
}, (err) => {
if (err && process.domain) {
debug('not recoverable, send to domain');
Expand Down

0 comments on commit 5aaeb01

Please sign in to comment.