handle computed properties correctly
This commit is contained in:
@@ -4907,7 +4907,12 @@ merge(Compressor.prototype, {
|
||||
expression: make_node(AST_Array, expr, {
|
||||
elements: props.map(function(prop) {
|
||||
var v = prop.value;
|
||||
return v instanceof AST_Accessor ? make_node(AST_Function, v, v) : v;
|
||||
if (v instanceof AST_Accessor) v = make_node(AST_Function, v, v);
|
||||
var k = prop.key;
|
||||
if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
|
||||
return make_sequence(prop, [ k, v ]);
|
||||
}
|
||||
return v;
|
||||
})
|
||||
}),
|
||||
property: make_node(AST_Number, this, {
|
||||
|
||||
@@ -1258,3 +1258,27 @@ array_hole: {
|
||||
}
|
||||
expect_stdout: "2 undefined 3"
|
||||
}
|
||||
|
||||
computed_property: {
|
||||
options = {
|
||||
properties: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
console.log({
|
||||
a: "bar",
|
||||
[console.log("foo")]: 42,
|
||||
}.a);
|
||||
}
|
||||
expect: {
|
||||
console.log([
|
||||
"bar",
|
||||
console.log("foo")
|
||||
][0]);
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user