aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4module.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-22 13:09:33 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-29 06:54:28 +0000
commitce1cd6468ad402003b7e7f3166c26485dd0bb9b1 (patch)
treede52cce3e4dabdcf9fdda3be61242c4ff6816dc3 /src/qml/jsruntime/qv4module.cpp
parent697564810f94ba32792ae714ca861e330bb4c657 (diff)
Fix handling of uninitialized exports when iterating module namespace objects
We must throw reference errors when the iteration reaches an uninitialized export. As with other module namespace cases we don't know at the call site that we're dealing with this special object, we must throw the reference error inside the iterator. That brings in the additional complexity that we can use the iterator to get a list of all names (should not throw) as well as to retrieve the values (throw on uninit). We make the distinction inside the ::next() function based on whether a Property pointer was provided, which requires slightly different variants inside the ObjectIterator that uses the internal iterator. On the upside this avoids value copying when they would be unused otherwise. Change-Id: Iac45d0ed39bea861ea92db875821225c0feb9391 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4module.cpp')
-rw-r--r--src/qml/jsruntime/qv4module.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
index 6b15637d49..2db229e2b0 100644
--- a/src/qml/jsruntime/qv4module.cpp
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -202,8 +202,13 @@ PropertyKey ModuleNamespaceIterator::next(const Object *o, Property *pd, Propert
Scope scope(module->engine());
ScopedString exportName(scope, scope.engine->newString(exportedNames.at(exportIndex)));
exportIndex++;
- if (pd)
- pd->value = *module->d()->unit->resolveExport(exportName);
+ const Value *v = module->d()->unit->resolveExport(exportName);
+ if (pd) {
+ if (v->isEmpty())
+ scope.engine->throwReferenceError(exportName);
+ else
+ pd->value = *v;
+ }
return exportName->toPropertyKey();
}
return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);