diff --git a/lib/repl.js b/lib/repl.js index 60b68dc05b4c6a..3db04b7718ab20 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -78,10 +78,6 @@ exports.writer = util.inspect; exports._builtinLibs = internalModule.builtinLibs; -const BLOCK_SCOPED_ERROR = 'Block-scoped declarations (let, const, function, ' + - 'class) not yet supported outside strict mode'; - - class LineParser { constructor() { @@ -266,7 +262,6 @@ function REPLServer(prompt, code = code.replace(/\n$/, ''); code = preprocess(code); - var retry = false; var input = code; var err, result, wrappedErr; // first, create the Script object to check the syntax @@ -277,9 +272,9 @@ function REPLServer(prompt, while (true) { try { if (!/^\s*$/.test(code) && - (self.replMode === exports.REPL_MODE_STRICT || retry)) { - // "void 0" keeps the repl from returning "use strict" as the - // result value for let/const statements. + self.replMode === exports.REPL_MODE_STRICT) { + // "void 0" keeps the repl from returning "use strict" as the result + // value for statements and declarations that don't return a value. code = `'use strict'; void 0;\n${code}`; } var script = vm.createScript(code, { @@ -288,17 +283,11 @@ function REPLServer(prompt, }); } catch (e) { debug('parse error %j', code, e); - if (self.replMode === exports.REPL_MODE_MAGIC && - e.message === BLOCK_SCOPED_ERROR && - !retry || self.wrappedCmd) { - if (self.wrappedCmd) { - self.wrappedCmd = false; - // unwrap and try again - code = `${input.substring(1, input.length - 2)}\n`; - wrappedErr = e; - } else { - retry = true; - } + if (self.wrappedCmd) { + self.wrappedCmd = false; + // unwrap and try again + code = `${input.substring(1, input.length - 2)}\n`; + wrappedErr = e; continue; } // preserve original error for wrapped command