diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-06 08:42:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-21 13:30:48 +0000 |
commit | 45d39a1685e72975dd9bd4d3e4a67aab59eeae48 (patch) | |
tree | 61e55f0f733e11c144c2c82ce1725cce28aeab88 /src/qml/parser/qqmljsast.cpp | |
parent | ce18e987d4ea623c0db6d10f2a97a16b639a234e (diff) |
Fix array destructuring nested in a rest element
Change-Id: I3a8c15fe221bff04a3b9b21ed8c0b06c04770a3d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast.cpp')
-rw-r--r-- | src/qml/parser/qqmljsast.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
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<IdentifierExpression *>(lhs)) { bindingIdentifier = i->name.toString(); identifierToken = i->identifierToken; |