diff options
-rw-r--r-- | lib/compress.js | 3 | ||||
-rw-r--r-- | test/compress/hoist_props.js | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index cfe37d0b..f3fc5e0e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5074,6 +5074,9 @@ merge(Compressor.prototype, { && right.properties.length > 0 && all(right.properties, function(prop) { return prop instanceof AST_ObjectKeyVal; + }) + && all(def.references, function(ref) { + return ref.fixed_value() === right; }); } }); diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js index a73df1f5..4fcbd796 100644 --- a/test/compress/hoist_props.js +++ b/test/compress/hoist_props.js @@ -972,3 +972,26 @@ issue_3871: { } expect_stdout: "PASS" } + +issue_3945: { + options = { + hoist_props: true, + reduce_vars: true, + } + input: { + function f() { + o.p; + var o = { + q: 0, + }; + } + } + expect: { + function f() { + o.p; + var o = { + q: 0, + }; + } + } +} |