File tree Expand file tree Collapse file tree 2 files changed +92
-4
lines changed Expand file tree Collapse file tree 2 files changed +92
-4
lines changed Original file line number Diff line number Diff line change @@ -1441,11 +1441,13 @@ Compressor.prototype.compress = function(node) {
1441
1441
break;
1442
1442
}
1443
1443
if (!ref.fixed) ref.fixed = d.fixed === 0 ? fixed : d.fixed;
1444
- var parent;
1445
- if (value instanceof AST_Lambda
1446
- && !((parent = tw.parent()) instanceof AST_Call && parent.expression === ref)) {
1447
- mark_fn_def(tw, d, value);
1444
+ if (!value && fixed) value = fixed instanceof AST_Node ? fixed : fixed();
1445
+ if (!(value instanceof AST_Lambda)) return;
1446
+ if (d.fixed) {
1447
+ var parent = tw.parent();
1448
+ if (parent instanceof AST_Call && parent.expression === ref) return;
1448
1449
}
1450
+ mark_fn_def(tw, d, value);
1449
1451
});
1450
1452
def(AST_Template, function(tw, descend) {
1451
1453
var node = this;
Original file line number Diff line number Diff line change @@ -8062,3 +8062,89 @@ issue_5716_5: {
8062
8062
}
8063
8063
expect_stdout: "42"
8064
8064
}
8065
+
8066
+ issue_5730_1: {
8067
+ options = {
8068
+ evaluate : true ,
8069
+ reduce_vars : true ,
8070
+ toplevel : true ,
8071
+ unused : true ,
8072
+ }
8073
+ input: {
8074
+ var a = "PASS" ;
8075
+ L: {
8076
+ var f = function ( ) {
8077
+ console . log ( a ) ;
8078
+ } ;
8079
+ }
8080
+ f ( ) ;
8081
+ a ++ ;
8082
+ }
8083
+ expect: {
8084
+ var a = "PASS" ;
8085
+ var f = function ( ) {
8086
+ console . log ( a ) ;
8087
+ } ;
8088
+ f ( ) ;
8089
+ a ++ ;
8090
+ }
8091
+ expect_stdout: "PASS"
8092
+ }
8093
+
8094
+ issue_5730_2: {
8095
+ options = {
8096
+ evaluate : true ,
8097
+ reduce_vars : true ,
8098
+ toplevel : true ,
8099
+ unused : true ,
8100
+ }
8101
+ input: {
8102
+ var a = "PASS" ;
8103
+ try {
8104
+ var f = function ( ) {
8105
+ console . log ( a ) ;
8106
+ } ;
8107
+ } finally { }
8108
+ f ( ) ;
8109
+ a ++ ;
8110
+ }
8111
+ expect: {
8112
+ var a = "PASS" ;
8113
+ try {
8114
+ var f = function ( ) {
8115
+ console . log ( a ) ;
8116
+ } ;
8117
+ } finally { }
8118
+ f ( ) ;
8119
+ a ++ ;
8120
+ }
8121
+ expect_stdout: "PASS"
8122
+ }
8123
+
8124
+ issue_5730_3: {
8125
+ options = {
8126
+ evaluate : true ,
8127
+ reduce_vars : true ,
8128
+ toplevel : true ,
8129
+ unused : true ,
8130
+ }
8131
+ input: {
8132
+ var f , a = "PASS" ;
8133
+ L: {
8134
+ f = function ( ) {
8135
+ console . log ( a ) ;
8136
+ } ;
8137
+ }
8138
+ f ( ) ;
8139
+ a ++ ;
8140
+ }
8141
+ expect: {
8142
+ var f , a = "PASS" ;
8143
+ f = function ( ) {
8144
+ console . log ( a ) ;
8145
+ } ;
8146
+ f ( ) ;
8147
+ a ++ ;
8148
+ }
8149
+ expect_stdout: "PASS"
8150
+ }
You can’t perform that action at this time.
0 commit comments