13
lib/scope.js
13
lib/scope.js
@@ -64,19 +64,20 @@ SymbolDef.prototype = {
|
|||||||
this.references.forEach(fn);
|
this.references.forEach(fn);
|
||||||
},
|
},
|
||||||
mangle: function(options) {
|
mangle: function(options) {
|
||||||
var cache = options.cache && options.cache.props;
|
if (this.mangled_name) return;
|
||||||
if (this.global && cache && cache.has(this.name)) {
|
var cache = this.global && options.cache && options.cache.props;
|
||||||
|
if (cache && cache.has(this.name)) {
|
||||||
this.mangled_name = cache.get(this.name);
|
this.mangled_name = cache.get(this.name);
|
||||||
} else if (!this.mangled_name && !this.unmangleable(options)) {
|
} else if (this.unmangleable(options)) {
|
||||||
|
names_in_use(this.scope, options).set(this.name, true);
|
||||||
|
} else {
|
||||||
var def = this.redefined();
|
var def = this.redefined();
|
||||||
if (def) {
|
if (def) {
|
||||||
this.mangled_name = def.mangled_name || def.name;
|
this.mangled_name = def.mangled_name || def.name;
|
||||||
} else {
|
} else {
|
||||||
this.mangled_name = next_mangled_name(this, options);
|
this.mangled_name = next_mangled_name(this, options);
|
||||||
}
|
}
|
||||||
if (this.global && cache) {
|
if (cache) cache.set(this.name, this.mangled_name);
|
||||||
cache.set(this.name, this.mangled_name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
redefined: function() {
|
redefined: function() {
|
||||||
|
|||||||
@@ -1855,3 +1855,20 @@ issue_5338: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5476: {
|
||||||
|
mangle = {
|
||||||
|
keep_fargs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(n) {
|
||||||
|
const a = 42;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(n) {
|
||||||
|
const o = 42;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2020,3 +2020,23 @@ issue_5338: {
|
|||||||
expect_stdout: ReferenceError("a is not defined")
|
expect_stdout: ReferenceError("a is not defined")
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5476: {
|
||||||
|
mangle = {
|
||||||
|
keep_fargs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
console.log(function(n) {
|
||||||
|
let a;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
console.log(function(n) {
|
||||||
|
let o;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2329,7 +2329,7 @@ function is_error_tdz(ex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function is_error_spread(ex) {
|
function is_error_spread(ex) {
|
||||||
return ex.name == "TypeError" && /Found non-callable @@iterator| is not iterable| not a function/.test(ex.message);
|
return ex.name == "TypeError" && /Found non-callable @@iterator| is not iterable| not a function|Symbol\(Symbol\.iterator\)/.test(ex.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_error_recursion(ex) {
|
function is_error_recursion(ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user