fix corner case in hoist_props (#3947)

fixes #3945
This commit is contained in:
Alex Lam S.L
2020-06-02 16:51:06 +01:00
committed by GitHub
parent c97ad98f92
commit e2e4b7fb37
2 changed files with 26 additions and 0 deletions

View File

@@ -5074,6 +5074,9 @@ merge(Compressor.prototype, {
&& right.properties.length > 0 && right.properties.length > 0
&& all(right.properties, function(prop) { && all(right.properties, function(prop) {
return prop instanceof AST_ObjectKeyVal; return prop instanceof AST_ObjectKeyVal;
})
&& all(def.references, function(ref) {
return ref.fixed_value() === right;
}); });
} }
}); });

View File

@@ -972,3 +972,26 @@ issue_3871: {
} }
expect_stdout: "PASS" 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,
};
}
}
}