File tree Expand file tree Collapse file tree 2 files changed +57
-1
lines changed
Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -10928,9 +10928,11 @@ Compressor.prototype.compress = function(node) {
1092810928 && (value = can_flatten_body(stat))) {
1092910929 var replacing = exp === fn || def.single_use && def.references.length - def.replaced == 1;
1093010930 if (can_substitute_directly()) {
10931+ self._optimized = true;
10932+ var retValue = value.optimize(compressor).clone(true);
1093110933 var args = self.args.slice();
1093210934 var refs = [];
10933- var retValue = value.optimize(compressor).clone(true) .transform(new TreeTransformer(function(node) {
10935+ retValue = retValue .transform(new TreeTransformer(function(node) {
1093410936 if (node instanceof AST_SymbolRef) {
1093510937 var def = node.definition();
1093610938 if (fn.variables.get(node.name) !== def) {
Original file line number Diff line number Diff line change @@ -8917,3 +8917,57 @@ issue_5841_2: {
89178917 "foo" ,
89188918 ]
89198919}
8920+
8921+ issue_5851_1: {
8922+ options = {
8923+ inline : true ,
8924+ reduce_vars : true ,
8925+ toplevel : true ,
8926+ }
8927+ input: {
8928+ console . log ( "PASS" ) && f ( ) ;
8929+ function f ( ) {
8930+ return f ( ) ;
8931+ }
8932+ f ;
8933+ }
8934+ expect: {
8935+ console . log ( "PASS" ) && f ( ) ;
8936+ function f ( ) {
8937+ return f ( ) ;
8938+ }
8939+ f ;
8940+ }
8941+ expect_stdout: "PASS"
8942+ }
8943+
8944+ issue_5851_2: {
8945+ options = {
8946+ conditionals : true ,
8947+ inline : true ,
8948+ passes : 2 ,
8949+ reduce_vars : true ,
8950+ side_effects : true ,
8951+ toplevel : true ,
8952+ unused : true ,
8953+ }
8954+ input: {
8955+ var a = f ( ) ;
8956+ f ( ) ;
8957+ function f ( ) {
8958+ if ( console . log ( "foo" ) )
8959+ console && f ( ) ;
8960+ }
8961+ }
8962+ expect: {
8963+ f ( ) ;
8964+ f ( ) ;
8965+ function f ( ) {
8966+ console . log ( "foo" ) && console && f ( ) ;
8967+ }
8968+ }
8969+ expect_stdout: [
8970+ "foo" ,
8971+ "foo" ,
8972+ ]
8973+ }
You can’t perform that action at this time.
0 commit comments