aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-07 10:23:13 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-07 10:32:04 +0000
commit06e0ec7cfc6e990c1101a2b4c15452d3c10b6816 (patch)
treeb82116cf9bb139ffdfd257a6c53e71866d1e4a57
parentff5bc526b4868aef9fb3a551afc5636b308a3d83 (diff)
Fix a smaller bug in IteratorClose
Throw the correct error in all cases Change-Id: Ic8f146cf13db605cb54cb8c96aaf0b3a1b9cca96 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp33
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations1
2 files changed, 20 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index b59b9c3f50..4e1993d45f 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -862,29 +862,36 @@ ReturnedValue Runtime::method_iteratorClose(ExecutionEngine *engine, const Value
return Encode::undefined();
Scope scope(engine);
- bool hadException = engine->hasException;
ScopedValue e(scope);
+ bool hadException = engine->hasException;
if (hadException) {
e = *engine->exceptionValue;
engine->hasException = false;
}
- ScopedFunctionObject f(scope, static_cast<const Object &>(iterator).get(engine->id_return()));
- ScopedObject o(scope);
- if (f) {
- JSCallData cData(scope, 0, nullptr, &iterator);
- o = f->call(cData);
- }
- if (hadException || !f) {
- *engine->exceptionValue = e;
- engine->hasException = hadException;
+
+ auto originalCompletion = [=]() {
+ if (hadException) {
+ *engine->exceptionValue = e;
+ engine->hasException = hadException;
+ }
return Encode::undefined();
+ };
+
+ ScopedValue ret(scope, static_cast<const Object &>(iterator).get(engine->id_return()));
+ ScopedObject o(scope);
+ if (!ret->isUndefined()) {
+ FunctionObject *f = ret->as<FunctionObject>();
+ o = f->call(&iterator, nullptr, 0);
+ if (engine->hasException && !hadException)
+ return Encode::undefined();
}
- if (engine->hasException)
- return Encode::undefined();
+ if (hadException || ret->isUndefined())
+ return originalCompletion();
if (!o)
return engine->throwTypeError();
- return Encode::undefined();
+
+ return originalCompletion();
}
ReturnedValue Runtime::method_destructureRestElement(ExecutionEngine *engine, const Value &iterator)
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index 97c71c7a60..a70a97bfb9 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -895,7 +895,6 @@ language/expressions/template-literal/tv-template-middle.js fails
language/expressions/template-literal/tv-template-tail.js fails
language/expressions/template-literal/tv-utf16-escape-sequence.js fails
language/expressions/template-literal/tv-zwnbsp.js fails
-language/expressions/yield/star-rhs-iter-thrw-violation-rtrn-get-err.js fails
language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails
language/function-code/each-param-has-own-scope.js sloppyFails
language/function-code/eval-param-env-with-computed-key.js sloppyFails