File tree Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -10825,7 +10825,7 @@ Compressor.prototype.compress = function(node) {
10825
10825
var begin;
10826
10826
var in_order = [];
10827
10827
var side_effects = false;
10828
- value.walk( new TreeWalker(function(node, descend) {
10828
+ var tw = new TreeWalker(function(node, descend) {
10829
10829
if (abort) return true;
10830
10830
if (node instanceof AST_Binary && lazy_op[node.operator]
10831
10831
|| node instanceof AST_Conditional) {
@@ -10841,7 +10841,7 @@ Compressor.prototype.compress = function(node) {
10841
10841
return;
10842
10842
}
10843
10843
if (def.init instanceof AST_LambdaDefinition) return abort = true;
10844
- if (is_lhs(node, this .parent())) return abort = true;
10844
+ if (is_lhs(node, tw .parent())) return abort = true;
10845
10845
var index = resolve_index(def);
10846
10846
if (!(begin < index)) begin = index;
10847
10847
if (!in_order) return;
@@ -10852,12 +10852,21 @@ Compressor.prototype.compress = function(node) {
10852
10852
}
10853
10853
return;
10854
10854
}
10855
+ if (side_effects) return;
10856
+ if (node instanceof AST_Assign && node.left instanceof AST_PropAccess) {
10857
+ node.left.expression.walk(tw);
10858
+ if (node.left instanceof AST_Sub) node.left.property.walk(tw);
10859
+ node.right.walk(tw);
10860
+ side_effects = true;
10861
+ return true;
10862
+ }
10855
10863
if (node.has_side_effects(compressor)) {
10856
10864
descend();
10857
10865
side_effects = true;
10858
10866
return true;
10859
10867
}
10860
- }));
10868
+ });
10869
+ value.walk(tw);
10861
10870
if (abort) return;
10862
10871
var end = self.args.length;
10863
10872
if (in_order && fn.argnames.length >= end) {
Original file line number Diff line number Diff line change @@ -5512,6 +5512,40 @@ substitute_use_strict: {
5512
5512
]
5513
5513
}
5514
5514
5515
+ substitute_assignment: {
5516
+ options = {
5517
+ evaluate : true ,
5518
+ inline : true ,
5519
+ passes : 2 ,
5520
+ properties : true ,
5521
+ reduce_vars : true ,
5522
+ side_effects : true ,
5523
+ toplevel : true ,
5524
+ unused : true ,
5525
+ }
5526
+ input: {
5527
+ function f ( a , b , c ) {
5528
+ a [ b ] = c ;
5529
+ }
5530
+ var o = { } ;
5531
+ f ( o , 42 , null ) ;
5532
+ f ( o , "foo" , "bar" ) ;
5533
+ for ( var k in o )
5534
+ console . log ( k , o [ k ] ) ;
5535
+ }
5536
+ expect: {
5537
+ var o = { } ;
5538
+ o [ 42 ] = null ;
5539
+ o . foo = "bar" ;
5540
+ for ( var k in o )
5541
+ console . log ( k , o [ k ] ) ;
5542
+ }
5543
+ expect_stdout: [
5544
+ "42 null" ,
5545
+ "foo bar" ,
5546
+ ]
5547
+ }
5548
+
5515
5549
issue_3833_1: {
5516
5550
options = {
5517
5551
inline : 3 ,
You can’t perform that action at this time.
0 commit comments