@@ -78,10 +78,6 @@ exports.writer = util.inspect;
78
78
exports . _builtinLibs = internalModule . builtinLibs ;
79
79
80
80
81
- const BLOCK_SCOPED_ERROR = 'Block-scoped declarations (let, const, function, ' +
82
- 'class) not yet supported outside strict mode' ;
83
-
84
-
85
81
class LineParser {
86
82
87
83
constructor ( ) {
@@ -266,7 +262,6 @@ function REPLServer(prompt,
266
262
code = code . replace ( / \n $ / , '' ) ;
267
263
code = preprocess ( code ) ;
268
264
269
- var retry = false ;
270
265
var input = code ;
271
266
var err , result , wrappedErr ;
272
267
// first, create the Script object to check the syntax
@@ -277,9 +272,9 @@ function REPLServer(prompt,
277
272
while ( true ) {
278
273
try {
279
274
if ( ! / ^ \s * $ / . test ( code ) &&
280
- ( self . replMode === exports . REPL_MODE_STRICT || retry ) ) {
281
- // "void 0" keeps the repl from returning "use strict" as the
282
- // result value for let/const statements.
275
+ self . replMode === exports . REPL_MODE_STRICT ) {
276
+ // "void 0" keeps the repl from returning "use strict" as the result
277
+ // value for statements and declarations that don't return a value .
283
278
code = `'use strict'; void 0;\n${ code } ` ;
284
279
}
285
280
var script = vm . createScript ( code , {
@@ -288,17 +283,11 @@ function REPLServer(prompt,
288
283
} ) ;
289
284
} catch ( e ) {
290
285
debug ( 'parse error %j' , code , e ) ;
291
- if ( self . replMode === exports . REPL_MODE_MAGIC &&
292
- e . message === BLOCK_SCOPED_ERROR &&
293
- ! retry || self . wrappedCmd ) {
294
- if ( self . wrappedCmd ) {
295
- self . wrappedCmd = false ;
296
- // unwrap and try again
297
- code = `${ input . substring ( 1 , input . length - 2 ) } \n` ;
298
- wrappedErr = e ;
299
- } else {
300
- retry = true ;
301
- }
286
+ if ( self . wrappedCmd ) {
287
+ self . wrappedCmd = false ;
288
+ // unwrap and try again
289
+ code = `${ input . substring ( 1 , input . length - 2 ) } \n` ;
290
+ wrappedErr = e ;
302
291
continue ;
303
292
}
304
293
// preserve original error for wrapped command
0 commit comments