aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-04 14:59:47 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-21 13:30:38 +0000
commit77c22af561f49bc6a78010564d33fc86eb831519 (patch)
tree6e4c09c7f833d994c085dba8c08d6e117be6a23b /src/qml/compiler/qv4codegen.cpp
parent3adc6dcf5ea078c9a365a63fb99f7869fd070cc2 (diff)
Fix handling of elisions in destructuring expressions
We need to iterator over elisions at the end, as those could trigger side effects by calling iterator.next() Change-Id: Ieb5fa3562b6e60fdf179fa228510b2eeaaf9da30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 2aa1cef451..1a47730979 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -595,7 +595,7 @@ void Codegen::destructureElementList(const Codegen::Reference &array, PatternEle
Instruction::IteratorNext next;
next.value = iteratorValue.stackSlot();
bytecodeGenerator->addInstruction(next);
- bool last = !p->next;
+ bool last = !p->next || (!p->next->elision && !p->next->element);
if (last)
iteratorDone.storeConsumeAccumulator();
if (e->type != PatternElement::RestElement) {
@@ -833,6 +833,9 @@ bool Codegen::visit(ArrayPattern *ast)
};
for (PatternElementList *it = ast->elements; it; it = it->next) {
+ for (Elision *elision = it->elision; elision; elision = elision->next)
+ push(nullptr);
+
PatternElement *e = it->element;
if (!e)
continue;
@@ -841,15 +844,10 @@ bool Codegen::visit(ArrayPattern *ast)
return false;
}
- for (Elision *elision = it->elision; elision; elision = elision->next)
- push(nullptr);
-
push(e->initializer);
if (hasError)
return false;
}
- for (Elision *elision = ast->elision; elision; elision = elision->next)
- push(nullptr);
if (args == -1) {
Q_ASSERT(argc == 0);