diff options
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 9 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 010848bdca..256ab6e0be 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1207,7 +1207,6 @@ bool Codegen::visit(ArrayPattern *ast) BytecodeGenerator::Label in = bytecodeGenerator->newLabel(); BytecodeGenerator::Label end = bytecodeGenerator->newLabel(); - BytecodeGenerator::Label done = bytecodeGenerator->newLabel(); { auto cleanup = [this, iterator, iteratorDone]() { @@ -1217,12 +1216,6 @@ bool Codegen::visit(ArrayPattern *ast) bytecodeGenerator->addInstruction(close); }; ControlFlowLoop flow(this, &end, &in, cleanup); - bytecodeGenerator->jump().link(in); - - BytecodeGenerator::Label body = bytecodeGenerator->label(); - - lhsValue.loadInAccumulator(); - pushAccumulator(); in.link(); iterator.loadInAccumulator(); @@ -1230,13 +1223,14 @@ bool Codegen::visit(ArrayPattern *ast) next.value = lhsValue.stackSlot(); next.done = iteratorDone.stackSlot(); bytecodeGenerator->addInstruction(next); - bytecodeGenerator->addJumpInstruction(Instruction::JumpFalse()).link(body); - bytecodeGenerator->jump().link(done); + bytecodeGenerator->addJumpInstruction(Instruction::JumpTrue()).link(end); + lhsValue.loadInAccumulator(); + pushAccumulator(); + + bytecodeGenerator->jump().link(in); end.link(); } - - done.link(); } else { RegisterScope innerScope(this); Reference expr = expression(it->element->initializer); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 788ecce1c5..aaaaf09925 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -361,6 +361,7 @@ private slots: void importLexicalVariables(); void hugeObject(); void templateStringTerminator(); + void arrayAndException(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8869,6 +8870,14 @@ void tst_qqmlecmascript::templateStringTerminator() QCOMPARE(value.toString(), QLatin1String("x123\ny^")); } +void tst_qqmlecmascript::arrayAndException() +{ + QJSEngine engine; + const QJSValue value = engine.evaluate("[...[],[,,$]]"); + // Should not crash + QVERIFY(value.isError()); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |