if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
var defs_by_id = Object.create(null);
- return self.transform(new TreeTransformer(function(node) {
+ return self.transform(new TreeTransformer(function(node, descend) {
if (node instanceof AST_VarDef) {
var sym = node.name, def, value;
if (sym.scope === self
&& !top_retain(def)
&& (value = sym.fixed_value()) === node.value
&& value instanceof AST_Object) {
+ descend(node, this);
var defs = new Dictionary();
var assignments = [];
value.properties.forEach(function(prop) {
}
expect_stdout: true
}
+
+issue_2519: {
+ options = {
+ collapse_vars: true,
+ evaluate: true,
+ hoist_props: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ function testFunc() {
+ var dimensions = {
+ minX: 5,
+ maxX: 6,
+ };
+ var scale = 1;
+ var d = {
+ x: (dimensions.maxX + dimensions.minX) / 2,
+ };
+ return d.x * scale;
+ }
+ console.log(testFunc());
+ }
+ expect: {
+ function testFunc() {
+ return 1 * ((6 + 5) / 2);
+ }
+ console.log(testFunc());
+ }
+ expect_stdout: "5.5"
+}