Commit 3e6858e 1 parent 8e88a18 commit 3e6858e Copy full SHA for 3e6858e
File tree 2 files changed +75
-10
lines changed
2 files changed +75
-10
lines changed Original file line number Diff line number Diff line change @@ -1375,14 +1375,15 @@ function isRecoverableError(e, code) {
1375
1375
if ( e && e . name === 'SyntaxError' ) {
1376
1376
var message = e . message ;
1377
1377
if ( message === 'Unterminated template literal' ||
1378
- message === 'Missing } in template expression ' ) {
1378
+ message === 'Unexpected end of input ' ) {
1379
1379
return true ;
1380
1380
}
1381
1381
1382
- if ( message . startsWith ( 'Unexpected end of input' ) ||
1383
- message . startsWith ( 'missing ) after argument list' ) ||
1384
- message . startsWith ( 'Unexpected token' ) )
1385
- return true ;
1382
+ if ( message === 'missing ) after argument list' ) {
1383
+ const frames = e . stack . split ( / \r ? \n / ) ;
1384
+ const pos = frames . findIndex ( ( f ) => f . match ( / ^ \s * \^ + $ / ) ) ;
1385
+ return pos > 0 && frames [ pos - 1 ] . length === frames [ pos ] . length ;
1386
+ }
1386
1387
1387
1388
if ( message === 'Invalid or unexpected token' )
1388
1389
return isCodeRecoverable ( code ) ;
Original file line number Diff line number Diff line change @@ -165,13 +165,23 @@ const errorTests = [
165
165
send : '.break' ,
166
166
expect : ''
167
167
} ,
168
- // Template expressions can cross lines
168
+ // Template expressions
169
169
{
170
170
send : '`io.js ${"1.0"' ,
171
+ expect : [
172
+ kSource ,
173
+ kArrow ,
174
+ '' ,
175
+ / ^ S y n t a x E r r o r : / ,
176
+ ''
177
+ ]
178
+ } ,
179
+ {
180
+ send : '`io.js ${' ,
171
181
expect : '... '
172
182
} ,
173
183
{
174
- send : '+ ".2"}`' ,
184
+ send : '"1.0" + ".2"}`' ,
175
185
expect : '\'io.js 1.0.2\''
176
186
} ,
177
187
// Dot prefix in multiline commands aren't treated as commands
@@ -636,14 +646,68 @@ const errorTests = [
636
646
} ,
637
647
// Do not parse `...[]` as a REPL keyword
638
648
{
639
- send : '...[]\n' ,
640
- expect : '... ... '
649
+ send : '...[]' ,
650
+ expect : [
651
+ kSource ,
652
+ kArrow ,
653
+ '' ,
654
+ / ^ S y n t a x E r r o r : / ,
655
+ ''
656
+ ]
641
657
} ,
642
658
// bring back the repl to prompt
643
659
{
644
660
send : '.break' ,
645
661
expect : ''
646
- }
662
+ } ,
663
+ {
664
+ send : 'console.log("Missing comma in arg list" process.version)' ,
665
+ expect : [
666
+ kSource ,
667
+ kArrow ,
668
+ '' ,
669
+ / ^ S y n t a x E r r o r : / ,
670
+ ''
671
+ ]
672
+ } ,
673
+ {
674
+ send : 'x = {\nfield\n{' ,
675
+ expect : [
676
+ '... ... {' ,
677
+ kArrow ,
678
+ '' ,
679
+ / ^ S y n t a x E r r o r : / ,
680
+ ''
681
+ ]
682
+ } ,
683
+ {
684
+ send : '(2 + 3))' ,
685
+ expect : [
686
+ kSource ,
687
+ kArrow ,
688
+ '' ,
689
+ / ^ S y n t a x E r r o r : / ,
690
+ ''
691
+ ]
692
+ } ,
693
+ {
694
+ send : 'if (typeof process === "object"); {' ,
695
+ expect : '... '
696
+ } ,
697
+ {
698
+ send : 'console.log("process is defined");' ,
699
+ expect : '... '
700
+ } ,
701
+ {
702
+ send : '} else {' ,
703
+ expect : [
704
+ kSource ,
705
+ kArrow ,
706
+ '' ,
707
+ / ^ S y n t a x E r r o r : / ,
708
+ ''
709
+ ]
710
+ } ,
647
711
] ;
648
712
649
713
const tcpTests = [
You can’t perform that action at this time.
0 commit comments