File tree Expand file tree Collapse file tree 4 files changed +42
-11
lines changed Expand file tree Collapse file tree 4 files changed +42
-11
lines changed Original file line number Diff line number Diff line change @@ -5605,21 +5605,25 @@ merge(Compressor.prototype, {
5605
5605
}
5606
5606
5607
5607
function mark ( sym , read ) {
5608
- if ( in_try ) push ( ) ;
5609
- var def = sym . definition ( ) , ldef ;
5608
+ var def = sym . definition ( ) , ldef , seg = segment ;
5609
+ if ( in_try ) {
5610
+ push ( ) ;
5611
+ seg = segment ;
5612
+ pop ( ) ;
5613
+ }
5610
5614
if ( def . id in references ) {
5611
5615
var refs = references [ def . id ] ;
5612
5616
if ( ! refs ) return ;
5613
- if ( refs . start . block !== segment . block ) return references [ def . id ] = false ;
5617
+ if ( refs . start . block !== seg . block ) return references [ def . id ] = false ;
5614
5618
refs . push ( sym ) ;
5615
- refs . end = segment ;
5619
+ refs . end = seg ;
5616
5620
if ( def . id in prev ) {
5617
5621
last [ prev [ def . id ] ] = null ;
5618
5622
} else if ( ! read ) {
5619
5623
return ;
5620
5624
}
5621
5625
} else if ( ( ldef = self . variables . get ( def . name ) ) !== def ) {
5622
- if ( ldef && root === segment ) references [ ldef . id ] = false ;
5626
+ if ( ldef && root === seg ) references [ ldef . id ] = false ;
5623
5627
return references [ def . id ] = false ;
5624
5628
} else if ( compressor . exposed ( def ) || NO_MERGE [ sym . name ] ) {
5625
5629
return references [ def . id ] = false ;
@@ -5628,13 +5632,13 @@ merge(Compressor.prototype, {
5628
5632
refs . push ( sym ) ;
5629
5633
references [ def . id ] = refs ;
5630
5634
if ( ! read ) {
5631
- refs . start = segment ;
5635
+ refs . start = seg ;
5632
5636
return first . push ( {
5633
5637
index : index ++ ,
5634
5638
definition : def ,
5635
5639
} ) ;
5636
5640
}
5637
- if ( segment . block !== self ) return references [ def . id ] = false ;
5641
+ if ( seg . block !== self ) return references [ def . id ] = false ;
5638
5642
refs . start = root ;
5639
5643
}
5640
5644
prev [ def . id ] = last . length ;
Original file line number Diff line number Diff line change @@ -1504,14 +1504,14 @@ function parse($TEXT, options) {
1504
1504
}
1505
1505
1506
1506
function export_default_decl ( ) {
1507
- switch ( S . token . value ) {
1508
- case "async" :
1507
+ if ( is ( "name" , "async" ) ) {
1509
1508
if ( ! is_token ( peek ( ) , "keyword" , "function" ) ) return ;
1510
1509
next ( ) ;
1511
1510
next ( ) ;
1512
1511
if ( ! is ( "operator" , "*" ) ) return maybe_named ( AST_AsyncDefun , function_ ( AST_AsyncFunction ) ) ;
1513
1512
next ( ) ;
1514
1513
return maybe_named ( AST_AsyncGeneratorDefun , function_ ( AST_AsyncGeneratorFunction ) ) ;
1514
+ } else if ( is ( "keyword" ) ) switch ( S . token . value ) {
1515
1515
case "class" :
1516
1516
next ( ) ;
1517
1517
return maybe_named ( AST_DefClass , class_ ( AST_ClassExpression ) ) ;
@@ -1524,13 +1524,13 @@ function parse($TEXT, options) {
1524
1524
}
1525
1525
1526
1526
var export_decl = embed_tokens ( function ( ) {
1527
- switch ( S . token . value ) {
1528
- case "async" :
1527
+ if ( is ( "name" , "async" ) ) {
1529
1528
next ( ) ;
1530
1529
expect_token ( "keyword" , "function" ) ;
1531
1530
if ( ! is ( "operator" , "*" ) ) return function_ ( AST_AsyncDefun ) ;
1532
1531
next ( ) ;
1533
1532
return function_ ( AST_AsyncGeneratorDefun ) ;
1533
+ } else if ( is ( "keyword" ) ) switch ( S . token . value ) {
1534
1534
case "class" :
1535
1535
next ( ) ;
1536
1536
return class_ ( AST_DefClass ) ;
Original file line number Diff line number Diff line change @@ -457,3 +457,10 @@ issue_4742_unused_2: {
457
457
a = "bar" ;
458
458
}
459
459
}
460
+
461
+ issue_4761: {
462
+ input: {
463
+ export default "function" == 42 ;
464
+ }
465
+ expect_exact: 'export default"function"==42;'
466
+ }
Original file line number Diff line number Diff line change @@ -3281,3 +3281,23 @@ issue_4759: {
3281
3281
}
3282
3282
expect_stdout: "undefined"
3283
3283
}
3284
+
3285
+ issue_4761: {
3286
+ options = {
3287
+ merge_vars : true ,
3288
+ toplevel : true ,
3289
+ }
3290
+ input: {
3291
+ var a = "FAIL" , b ;
3292
+ try {
3293
+ ! a && -- a && ( b = 0 ) [ console ] || console . log ( b ) ;
3294
+ } catch ( e ) { }
3295
+ }
3296
+ expect: {
3297
+ var a = "FAIL" , b ;
3298
+ try {
3299
+ ! a && -- a && ( b = 0 ) [ console ] || console . log ( b ) ;
3300
+ } catch ( e ) { }
3301
+ }
3302
+ expect_stdout: "undefined"
3303
+ }
You can’t perform that action at this time.
0 commit comments