fix mangle of destructuring parameters with computed properties (#2359)
fixes #2349
This commit is contained in:
@@ -2000,9 +2000,6 @@ function parse($TEXT, options) {
|
|||||||
names: ex.properties.map(to_fun_args)
|
names: ex.properties.map(to_fun_args)
|
||||||
}), default_seen_above);
|
}), default_seen_above);
|
||||||
} else if (ex instanceof AST_ObjectKeyVal) {
|
} else if (ex instanceof AST_ObjectKeyVal) {
|
||||||
if (ex.key instanceof AST_SymbolRef) {
|
|
||||||
ex.key = to_fun_args(ex.key, 0, [ex.key]);
|
|
||||||
}
|
|
||||||
ex.value = to_fun_args(ex.value, 0, [ex.key]);
|
ex.value = to_fun_args(ex.value, 0, [ex.key]);
|
||||||
return insert_default(ex, default_seen_above);
|
return insert_default(ex, default_seen_above);
|
||||||
} else if (ex instanceof AST_Hole) {
|
} else if (ex instanceof AST_Hole) {
|
||||||
|
|||||||
@@ -863,3 +863,75 @@ issue_2345: {
|
|||||||
]
|
]
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2349: {
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
function foo(boo, key) {
|
||||||
|
const value = boo.get();
|
||||||
|
return value.map(({[key]: bar}) => bar);
|
||||||
|
}
|
||||||
|
console.log(foo({
|
||||||
|
get: () => [ {
|
||||||
|
blah: 42
|
||||||
|
} ]
|
||||||
|
}, "blah"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function foo(o, n) {
|
||||||
|
const t = o.get();
|
||||||
|
return t.map(({[n]: o}) => o);
|
||||||
|
}
|
||||||
|
console.log(foo({
|
||||||
|
get: () => [ {
|
||||||
|
blah: 42
|
||||||
|
} ]
|
||||||
|
}, "blah"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"[ 42 ]",
|
||||||
|
]
|
||||||
|
node_version: ">=7"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2349b: {
|
||||||
|
options = {
|
||||||
|
arrows: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
ecma: 6,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 3,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
side_effects: true,
|
||||||
|
unsafe: true,
|
||||||
|
unsafe_arrows: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
mangle = {
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function foo(boo, key) {
|
||||||
|
const value = boo.get();
|
||||||
|
return value.map(function({[key]: bar}){ return bar; });
|
||||||
|
}
|
||||||
|
console.log(foo({
|
||||||
|
get: function() {
|
||||||
|
return [ {
|
||||||
|
blah: 42
|
||||||
|
} ];
|
||||||
|
}
|
||||||
|
}, "blah"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log([ {
|
||||||
|
blah: 42
|
||||||
|
} ].map(({["blah"]: l}) => l));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"[ 42 ]",
|
||||||
|
]
|
||||||
|
node_version: ">=7"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user