From 45d39a1685e72975dd9bd4d3e4a67aab59eeae48 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 6 Jun 2018 08:42:40 +0200 Subject: Fix array destructuring nested in a rest element Change-Id: I3a8c15fe221bff04a3b9b21ed8c0b06c04770a3d Reviewed-by: Simon Hausmann --- src/qml/parser/qqmljsast.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/qml/parser') diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index e9e33f7561..b338c5bbfe 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -399,28 +399,28 @@ bool PatternElement::convertLiteralToAssignmentPattern(MemoryPool *pool, SourceL *errorMessage = QString::fromLatin1("Invalid lhs expression after '...' in destructuring expression."); return false; } - bindingTarget = lhs; - return true; - } - type = PatternElement::Binding; + } else { + type = PatternElement::Binding; - if (BinaryExpression *b = init->binaryExpressionCast()) { - if (b->op != QSOperator::Assign) { - *errorLocation = b->operatorToken; - *errorMessage = QString::fromLatin1("Invalid assignment operation in destructuring expression"); + if (BinaryExpression *b = init->binaryExpressionCast()) { + if (b->op != QSOperator::Assign) { + *errorLocation = b->operatorToken; + *errorMessage = QString::fromLatin1("Invalid assignment operation in destructuring expression"); + return false; + } + lhs = b->left->leftHandSideExpressionCast(); + initializer = b->right; + Q_ASSERT(lhs); + } else { + lhs = init->leftHandSideExpressionCast(); + } + if (!lhs) { + *errorLocation = init->firstSourceLocation(); + *errorMessage = QString::fromLatin1("Destructuring target is not a left hand side expression."); return false; } - lhs = b->left->leftHandSideExpressionCast(); - initializer = b->right; - Q_ASSERT(lhs); - } else { - lhs = init->leftHandSideExpressionCast(); - } - if (!lhs) { - *errorLocation = init->firstSourceLocation(); - *errorMessage = QString::fromLatin1("Destructuring target is not a left hand side expression."); - return false; } + if (auto *i = cast(lhs)) { bindingIdentifier = i->name.toString(); identifierToken = i->identifierToken; -- cgit v1.2.3