diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-03-14 15:41:50 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-04-26 20:26:45 +0000 |
commit | 2ca47e49a25b92e70f6fa6c7a15cb7102a52435c (patch) | |
tree | 4800473ad11ba4d239880769e7c304defc1068a1 /src/qml/compiler/qv4codegen.cpp | |
parent | 3354628fd9e4c5f2255161a6ca8a5be63ff5bb89 (diff) | |
download | qtdeclarative-2ca47e49a25b92e70f6fa6c7a15cb7102a52435c.tar.gz |
Fix some bugs in binding destructuring
Change-Id: I4b18a88e443f3b263cbb1e2b5ca1ebbd353afa98
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index f7617c66de..99811c3779 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -421,6 +421,12 @@ void Codegen::initializeAndDestructureBindingElement(AST::BindingElement *e, con destructureElementList(varToStore, l); } else if (BindingPropertyList *p = e->propertyList()) { destructurePropertyList(varToStore, p); + } else if (e->name.isNull()) { + // empty binding pattern. For spec compatibility, try to coerce the argument to an object + varToStore.loadInAccumulator(); + Instruction::ToObject toObject; + bytecodeGenerator->addInstruction(toObject); + return; } } @@ -449,10 +455,10 @@ void Codegen::destructureElementList(const Codegen::Reference &array, BindingEle Reference idx = Reference::fromConst(this, Encode(index)); Reference property = Reference::fromSubscript(array, idx); - BindingElement *e = p->bindingElement(); - if (e) + if (BindingElement *e = p->bindingElement()) initializeAndDestructureBindingElement(e, property); - else { + else if (BindingRestElement *r = p->bindingRestElement()) { + Q_UNUSED(r); throwSyntaxError(bindingList->firstSourceLocation(), QString::fromLatin1("Support for rest elements in binding arrays not implemented!")); } } |