File tree 4 files changed +115
-0
lines changed
4 files changed +115
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
178
178
} ) ;
179
179
return true ;
180
180
}
181
+ if ( node instanceof AST_Switch ) {
182
+ node . expression . walk ( tw ) ;
183
+ walk_scope ( function ( ) {
184
+ walk_body ( node , tw ) ;
185
+ } ) ;
186
+ return true ;
187
+ }
181
188
if ( node instanceof AST_SwitchBranch ) {
182
189
node . init_vars ( scope ) ;
183
190
descend ( ) ;
Original file line number Diff line number Diff line change @@ -2204,3 +2204,30 @@ issue_5660: {
2204
2204
}
2205
2205
expect_stdout: true
2206
2206
}
2207
+
2208
+ issue_5787: {
2209
+ options = {
2210
+ unused : true ,
2211
+ }
2212
+ input: {
2213
+ console . log ( function ( ) {
2214
+ const a = 42 ;
2215
+ switch ( a ) {
2216
+ case 42 :
2217
+ const a = "PASS" ;
2218
+ return a ;
2219
+ }
2220
+ } ( ) ) ;
2221
+ }
2222
+ expect: {
2223
+ console . log ( function ( ) {
2224
+ const a = 42 ;
2225
+ switch ( a ) {
2226
+ case 42 :
2227
+ const a = "PASS" ;
2228
+ return a ;
2229
+ }
2230
+ } ( ) ) ;
2231
+ }
2232
+ expect_stdout: true
2233
+ }
Original file line number Diff line number Diff line change @@ -2537,3 +2537,32 @@ issue_5759: {
2537
2537
]
2538
2538
node_version: ">=4"
2539
2539
}
2540
+
2541
+ issue_5787: {
2542
+ options = {
2543
+ unused : true ,
2544
+ }
2545
+ input: {
2546
+ console . log ( function ( ) {
2547
+ let a = 42 ;
2548
+ switch ( a ) {
2549
+ case 42 :
2550
+ // Node.js v4 (vm): SyntaxError: Identifier 'a' has already been declared
2551
+ let a = "PASS" ;
2552
+ return a ;
2553
+ }
2554
+ } ( ) ) ;
2555
+ }
2556
+ expect: {
2557
+ console . log ( function ( ) {
2558
+ let a = 42 ;
2559
+ switch ( a ) {
2560
+ case 42 :
2561
+ let a = "PASS" ;
2562
+ return a ;
2563
+ }
2564
+ } ( ) ) ;
2565
+ }
2566
+ expect_stdout: "PASS"
2567
+ node_version: ">=6"
2568
+ }
Original file line number Diff line number Diff line change @@ -739,3 +739,55 @@ issue_3480_ie8_toplevel: {
739
739
}
740
740
expect_stdout: "PASS"
741
741
}
742
+
743
+ issue_5787_1: {
744
+ rename = true
745
+ input: {
746
+ console . log ( function ( ) {
747
+ const a = 42 ;
748
+ switch ( a ) {
749
+ case 42 :
750
+ const a = "PASS" ;
751
+ return a ;
752
+ }
753
+ } ( ) ) ;
754
+ }
755
+ expect: {
756
+ console . log ( function ( ) {
757
+ const a = 42 ;
758
+ switch ( a ) {
759
+ case 42 :
760
+ const a = "PASS" ;
761
+ return a ;
762
+ }
763
+ } ( ) ) ;
764
+ }
765
+ expect_stdout: true
766
+ }
767
+
768
+ issue_5787_2: {
769
+ rename = true
770
+ input: {
771
+ console . log ( function ( ) {
772
+ let a = 42 ;
773
+ switch ( a ) {
774
+ case 42 :
775
+ // Node.js v4 (vm): SyntaxError: Identifier 'a' has already been declared
776
+ let a = "PASS" ;
777
+ return a ;
778
+ }
779
+ } ( ) ) ;
780
+ }
781
+ expect: {
782
+ console . log ( function ( ) {
783
+ let a = 42 ;
784
+ switch ( a ) {
785
+ case 42 :
786
+ let b = "PASS" ;
787
+ return b ;
788
+ }
789
+ } ( ) ) ;
790
+ }
791
+ expect_stdout: "PASS"
792
+ node_version: ">=6"
793
+ }
You can’t perform that action at this time.
0 commit comments