aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js8
-rw-r--r--test/compress/functions.js46
2 files changed, 52 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 3d1b17f3..67884a13 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6130,8 +6130,12 @@ merge(Compressor.prototype, {
return;
}
if (node instanceof AST_Scope) return abort = true;
- var def;
- if (node instanceof AST_SymbolRef && fn.variables.get(node.name) === (def = node.definition())) {
+ if (node instanceof AST_SymbolRef) {
+ var def = node.definition();
+ if (fn.variables.get(node.name) !== def) {
+ in_order = null;
+ return;
+ }
if (def.init instanceof AST_Defun) return abort = true;
if (is_lhs(node, this.parent())) return abort = true;
var index = resolve_index(def);
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 4dc685be..b088ca87 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -4062,3 +4062,49 @@ issue_3777_2: {
}
expect_stdout: "PASS"
}
+
+issue_3821_1: {
+ options = {
+ inline: true,
+ }
+ input: {
+ var a = 0;
+ console.log(function(b) {
+ return +a + b;
+ }(--a));
+ }
+ expect: {
+ var a = 0;
+ console.log(function(b) {
+ return +a + b;
+ }(--a));
+ }
+ expect_stdout: "-2"
+}
+
+issue_3821_2: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var a = "PASS";
+ function f(g, b) {
+ return g(), b;
+ }
+ console.log(f(function() {
+ a = "FAIL";
+ }, a));
+ }
+ expect: {
+ var a = "PASS";
+ function f(g, b) {
+ return g(), b;
+ }
+ console.log(f(function() {
+ a = "FAIL";
+ }, a));
+ }
+ expect_stdout: "PASS"
+}