@@ -6651,7 +6651,7 @@ merge(Compressor.prototype, {
|
|||||||
var s = def.scope;
|
var s = def.scope;
|
||||||
do {
|
do {
|
||||||
s = s.parent_scope;
|
s = s.parent_scope;
|
||||||
if (s.variables.has(node.name)) return false;
|
if (s.var_names()[node.name]) return false;
|
||||||
} while (s !== scope);
|
} while (s !== scope);
|
||||||
return true;
|
return true;
|
||||||
}) ? make_node(AST_Var, self, {
|
}) ? make_node(AST_Var, self, {
|
||||||
|
|||||||
11
lib/scope.js
11
lib/scope.js
@@ -82,10 +82,13 @@ SymbolDef.prototype = {
|
|||||||
redefined: function() {
|
redefined: function() {
|
||||||
var scope = this.defun;
|
var scope = this.defun;
|
||||||
if (!scope) return;
|
if (!scope) return;
|
||||||
var def = scope.variables.get(this.name);
|
var name = this.name;
|
||||||
if (!def && scope instanceof AST_Toplevel) def = scope.globals.get(this.name);
|
var def = scope.variables.get(name)
|
||||||
if (!def || def === this) return;
|
|| scope instanceof AST_Toplevel && scope.globals.get(name)
|
||||||
return def.redefined() || def;
|
|| this.orig[0] instanceof AST_SymbolConst && find_if(function(def) {
|
||||||
|
return def.name == name;
|
||||||
|
}, scope.enclosed);
|
||||||
|
if (def && def !== this) return def.redefined() || def;
|
||||||
},
|
},
|
||||||
unmangleable: function(options) {
|
unmangleable: function(options) {
|
||||||
return this.global && !options.toplevel
|
return this.global && !options.toplevel
|
||||||
|
|||||||
@@ -930,3 +930,36 @@ issue_4207: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4210: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
try {
|
||||||
|
throw 42;
|
||||||
|
} catch (e) {
|
||||||
|
const a = typeof e;
|
||||||
|
console.log(a);
|
||||||
|
} finally {
|
||||||
|
return a = "foo";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
try {
|
||||||
|
throw 42;
|
||||||
|
} catch (e) {
|
||||||
|
const a = typeof e;
|
||||||
|
console.log(a);
|
||||||
|
} finally {
|
||||||
|
return a = "foo";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user