From bead103138c0d9dff3c9f927c9c4e2f44ee7db4c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 21 Aug 2018 16:51:17 +0200 Subject: Implement the dead temporal zone With const and let it is possible to access the declared member before initialization. This is expected to throw a type reference error at run-time. We initialize such variables with the empty value when entering their scope and check upon access for that. For locals we place the lexically scoped variables at the end. For register allocated lexical variables we group them into one batch and remember the index/size. Change-Id: Icb493ee0de0525bb682e1bc58981a4dfd33f750e Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4module.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/qml/jsruntime/qv4module.cpp') diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp index 583d0c3756..c892749a11 100644 --- a/src/qml/jsruntime/qv4module.cpp +++ b/src/qml/jsruntime/qv4module.cpp @@ -70,6 +70,9 @@ void Heap::Module::init(ExecutionEngine *engine, CompiledData::CompilationUnit * scope->locals.alloc = locals; scope->nArgs = 0; + // Prepare the temporal dead zone + scope->setupLocalTemporalDeadZone(moduleFunction->compiledFunction); + Scope valueScope(engine); // It's possible for example to re-export an import, for example: @@ -106,7 +109,7 @@ 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) + if (!v || v->isEmpty()) return Encode::undefined(); return v->asReturnedValue(); } -- cgit v1.2.3