File tree 3 files changed +71
-2
lines changed
3 files changed +71
-2
lines changed Original file line number Diff line number Diff line change @@ -1275,7 +1275,14 @@ Compressor.prototype.compress = function(node) {
1275
1275
descend();
1276
1276
var node = this;
1277
1277
var expr = node.expression;
1278
- if (!node.optional && expr instanceof AST_SymbolRef) access(tw, expr.definition());
1278
+ if (!node.optional) {
1279
+ while (expr instanceof AST_Assign && expr.operator == "=") {
1280
+ var lhs = expr.left;
1281
+ if (lhs instanceof AST_SymbolRef) access(tw, lhs.definition());
1282
+ expr = expr.right;
1283
+ }
1284
+ if (expr instanceof AST_SymbolRef) access(tw, expr.definition());
1285
+ }
1279
1286
return true;
1280
1287
});
1281
1288
def(AST_For, function(tw, descend, compressor) {
@@ -1385,6 +1392,11 @@ Compressor.prototype.compress = function(node) {
1385
1392
pop(tw);
1386
1393
} else {
1387
1394
descend();
1395
+ while (expr instanceof AST_Assign && expr.operator == "=") {
1396
+ var lhs = expr.left;
1397
+ if (lhs instanceof AST_SymbolRef) access(tw, lhs.definition());
1398
+ expr = expr.right;
1399
+ }
1388
1400
if (expr instanceof AST_SymbolRef) access(tw, expr.definition());
1389
1401
}
1390
1402
return true;
@@ -8056,6 +8068,7 @@ Compressor.prototype.compress = function(node) {
8056
8068
if (node.write_only === "p" && node.right.may_throw_on_access(compressor, true)) return;
8057
8069
var assign = props.assign;
8058
8070
if (assign) {
8071
+ initializations.add(node_def.id, assign.left);
8059
8072
assign.write_only = true;
8060
8073
assign.walk(tw);
8061
8074
}
Original file line number Diff line number Diff line change @@ -3814,3 +3814,59 @@ issue_5533_drop_fargs: {
3814
3814
}
3815
3815
expect_stdout: "PASS"
3816
3816
}
3817
+
3818
+ issue_5908_1: {
3819
+ options = {
3820
+ collapse_vars : true ,
3821
+ pure_getters : "strict" ,
3822
+ reduce_vars : true ,
3823
+ unused : true ,
3824
+ }
3825
+ input: {
3826
+ var a = function ( b ) {
3827
+ function f ( ) { }
3828
+ b = f . prototype ;
3829
+ b . p = 42 ;
3830
+ b . q = "PASS" ;
3831
+ return f ;
3832
+ } ( ) ;
3833
+ console . log ( a . prototype . q ) ;
3834
+ }
3835
+ expect: {
3836
+ var a = function ( b ) {
3837
+ function f ( ) { }
3838
+ ( b = f . prototype ) . p = 42 ;
3839
+ b . q = "PASS" ;
3840
+ return f ;
3841
+ } ( ) ;
3842
+ console . log ( a . prototype . q ) ;
3843
+ }
3844
+ expect_stdout: "PASS"
3845
+ }
3846
+
3847
+ issue_5908_2: {
3848
+ options = {
3849
+ pure_getters : "strict" ,
3850
+ reduce_vars : true ,
3851
+ unused : true ,
3852
+ }
3853
+ input: {
3854
+ var a = function ( b ) {
3855
+ function f ( ) { }
3856
+ ( b = f . prototype ) . p = 42 ;
3857
+ b . q = "PASS" ;
3858
+ return f ;
3859
+ } ( ) ;
3860
+ console . log ( a . prototype . q ) ;
3861
+ }
3862
+ expect: {
3863
+ var a = function ( b ) {
3864
+ function f ( ) { }
3865
+ ( b = f . prototype ) . p = 42 ;
3866
+ b . q = "PASS" ;
3867
+ return f ;
3868
+ } ( ) ;
3869
+ console . log ( a . prototype . q ) ;
3870
+ }
3871
+ expect_stdout: "PASS"
3872
+ }
Original file line number Diff line number Diff line change @@ -7139,7 +7139,7 @@ reduce_cross_reference_2_toplevel: {
7139
7139
reduce_cross_reference_3: {
7140
7140
options = {
7141
7141
collapse_vars : true ,
7142
- passes : 3 ,
7142
+ passes : 4 ,
7143
7143
pure_getters : "strict" ,
7144
7144
reduce_vars : true ,
7145
7145
sequences : true ,
You can’t perform that action at this time.
0 commit comments