File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,7 +151,17 @@ merge(Compressor.prototype, {
151151 node = node . hoist_declarations ( this ) ;
152152 was_scope = true ;
153153 }
154+ // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
155+ // would call AST_Node.transform() if a different instance of AST_Node is
156+ // produced after OPT().
157+ // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
158+ // Migrate and defer all children's AST_Node.transform() to below, which
159+ // will now happen after this parent AST_Node has been properly substituted
160+ // thus gives a consistent AST snapshot.
154161 descend ( node , this ) ;
162+ // Existing code relies on how AST_Node.optimize() worked, and omitting the
163+ // following replacement call would result in degraded efficiency of both
164+ // output and performance.
155165 descend ( node , this ) ;
156166 var opt = node . optimize ( this ) ;
157167 if ( was_scope && opt instanceof AST_Scope ) {
You can’t perform that action at this time.
0 commit comments