File tree 3 files changed +76
-3
lines changed
3 files changed +76
-3
lines changed Original file line number Diff line number Diff line change @@ -10255,8 +10255,18 @@ Compressor.prototype.compress = function(node) {
10255
10255
return all(this.definitions, function(defn) {
10256
10256
return !defn.name.match_symbol(function(node) {
10257
10257
if (!(node instanceof AST_SymbolDeclaration)) return false;
10258
- if (node.definition().first_decl !== node) return true;
10259
- return !safe_from_tdz(compressor, node);
10258
+ var def = node.definition();
10259
+ if (def.first_decl !== node) return true;
10260
+ if (!safe_from_tdz(compressor, node)) return true;
10261
+ var defn_scope = node.scope;
10262
+ if (defn_scope instanceof AST_Scope) return false;
10263
+ return !all(def.references, function(ref) {
10264
+ var scope = ref.scope;
10265
+ do {
10266
+ if (scope === defn_scope) return true;
10267
+ } while (scope = scope.parent_scope);
10268
+ return false;
10269
+ });
10260
10270
}, true);
10261
10271
});
10262
10272
});
Original file line number Diff line number Diff line change @@ -2328,3 +2328,66 @@ issue_5741: {
2328
2328
expect_stdout: "PASS"
2329
2329
node_version: ">=4"
2330
2330
}
2331
+
2332
+ issue_5745_1: {
2333
+ options = {
2334
+ join_vars : true ,
2335
+ reduce_vars : true ,
2336
+ toplevel : true ,
2337
+ }
2338
+ input: {
2339
+ "use strict" ;
2340
+ {
2341
+ let f = function ( ) {
2342
+ return f && "PASS" ;
2343
+ } ;
2344
+ var a = f ( ) ;
2345
+ }
2346
+ a ;
2347
+ console . log ( a ) ;
2348
+ }
2349
+ expect: {
2350
+ "use strict" ;
2351
+ {
2352
+ let f = function ( ) {
2353
+ return f && "PASS" ;
2354
+ } ;
2355
+ var a = f ( ) ;
2356
+ }
2357
+ a ;
2358
+ console . log ( a ) ;
2359
+ }
2360
+ expect_stdout: "PASS"
2361
+ node_version: ">=4"
2362
+ }
2363
+
2364
+ issue_5745_2: {
2365
+ options = {
2366
+ join_vars : true ,
2367
+ reduce_vars : true ,
2368
+ toplevel : true ,
2369
+ }
2370
+ input: {
2371
+ "use strict" ;
2372
+ {
2373
+ let f = function ( ) {
2374
+ return f && "PASS" ;
2375
+ } ;
2376
+ var a = f ( ) ;
2377
+ a ;
2378
+ console . log ( a ) ;
2379
+ }
2380
+ }
2381
+ expect: {
2382
+ "use strict" ;
2383
+ {
2384
+ let f = function ( ) {
2385
+ return f && "PASS" ;
2386
+ } , a = f ( ) ;
2387
+ a ;
2388
+ console . log ( a ) ;
2389
+ }
2390
+ }
2391
+ expect_stdout: "PASS"
2392
+ node_version: ">=4"
2393
+ }
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ function infer_options(options) {
100
100
exports . default_options = function ( ) {
101
101
var defs = infer_options ( { 0 : 0 } ) ;
102
102
Object . keys ( defs ) . forEach ( function ( component ) {
103
- var options = { } ;
103
+ var options = { module : false } ;
104
104
options [ component ] = { 0 : 0 } ;
105
105
if ( options = infer_options ( options ) ) {
106
106
defs [ component ] = options ;
You can’t perform that action at this time.
0 commit comments