aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js16
-rw-r--r--test/compress/drop-unused.js31
2 files changed, 41 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 763aabd8..96229369 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3916,14 +3916,18 @@ merge(Compressor.prototype, {
} else if (node instanceof AST_Unary) {
if (node.write_only) sym = node.expression;
}
- if (!/strict/.test(compressor.option("pure_getters"))) return sym instanceof AST_SymbolRef && sym;
- while (sym instanceof AST_PropAccess && !sym.expression.may_throw_on_access(compressor)) {
- if (sym instanceof AST_Sub) props.unshift(sym.property);
- sym = sym.expression;
+ if (/strict/.test(compressor.option("pure_getters"))) {
+ while (sym instanceof AST_PropAccess && !sym.expression.may_throw_on_access(compressor)) {
+ if (sym instanceof AST_Sub) props.unshift(sym.property);
+ sym = sym.expression;
+ }
}
- return sym instanceof AST_SymbolRef && all(sym.definition().orig, function(sym) {
+ if (!(sym instanceof AST_SymbolRef)) return;
+ if (compressor.exposed(sym.definition())) return;
+ if (!all(sym.definition().orig, function(sym) {
return !(sym instanceof AST_SymbolLambda);
- }) && sym;
+ })) return;
+ return sym;
};
var in_use = [];
var in_use_ids = Object.create(null); // avoid expensive linear scans of in_use
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 2d2f3d43..99ab7b40 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -2413,3 +2413,34 @@ issue_3673: {
}
expect_stdout: "PASS"
}
+
+issue_3746: {
+ options = {
+ keep_fargs: "strict",
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ try {
+ A;
+ } catch (e) {
+ var e;
+ }
+ (function f(a) {
+ e = a;
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ try {
+ A;
+ } catch (e) {
+ var e;
+ }
+ (function(a) {
+ e = a;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}