Fix assignment to rest param element.
This commit is contained in:
@@ -53,9 +53,18 @@ let memberExpressionOptimisationVisitor = {
|
||||
state.deopted = true;
|
||||
} else {
|
||||
let {parentPath} = path;
|
||||
let grandparentPath = parentPath.parentPath;
|
||||
|
||||
// ex: args[0]
|
||||
if (parentPath.isMemberExpression({ computed: true, object: node })) {
|
||||
if (
|
||||
parentPath.isMemberExpression({ computed: true, object: node }) &&
|
||||
|
||||
// ex: `args[0] = "whatever"`
|
||||
!(
|
||||
grandparentPath.isAssignmentExpression() &&
|
||||
parentPath.node === grandparentPath.node.left
|
||||
)
|
||||
) {
|
||||
// if we know that this member expression is referencing a number then
|
||||
// we can safely optimise it
|
||||
let prop = parentPath.get("property");
|
||||
|
||||
Reference in New Issue
Block a user