aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4module.cpp')
-rw-r--r--src/qml/jsruntime/qv4module.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
index c892749a11..6b15637d49 100644
--- a/src/qml/jsruntime/qv4module.cpp
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -109,8 +109,12 @@ ReturnedValue Module::virtualGet(const Managed *m, PropertyKey id, const Value *
const Value *v = module->d()->unit->resolveExport(expectedName);
if (hasProperty)
*hasProperty = v != nullptr;
- if (!v || v->isEmpty())
+ if (!v)
return Encode::undefined();
+ if (v->isEmpty()) {
+ ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
+ return scope.engine->throwReferenceError(propName);
+ }
return v->asReturnedValue();
}
@@ -129,10 +133,26 @@ PropertyAttributes Module::virtualGetOwnProperty(Managed *m, PropertyKey id, Pro
return Attr_Invalid;
}
if (p)
- p->value = v->asReturnedValue();
+ p->value = v->isEmpty() ? Encode::undefined() : v->asReturnedValue();
+ if (v->isEmpty()) {
+ ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
+ scope.engine->throwReferenceError(propName);
+ }
return Attr_Data | Attr_NotConfigurable;
}
+bool Module::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ if (id.isSymbol())
+ return Object::virtualHasProperty(m, id);
+
+ const Module *module = static_cast<const Module *>(m);
+ Scope scope(m->engine());
+ ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
+ const Value *v = module->d()->unit->resolveExport(expectedName);
+ return v != nullptr;
+}
+
bool Module::virtualPreventExtensions(Managed *)
{
return true;