From 16f18f68e37661f45047c913b9e6f9068dbc88a9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 22 Aug 2018 11:57:36 +0200 Subject: Fix scoping of the default export Default export variables should follow lexical scope and live therefore in the dead temporal zone (15.2.3.8). Change-Id: I959a1dc1cdd430825d6d207138efaef23394bd04 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compilercontext.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/qml/compiler/qv4compilercontext.cpp') diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp index ba9b270601..4ee6d2c179 100644 --- a/src/qml/compiler/qv4compilercontext.cpp +++ b/src/qml/compiler/qv4compilercontext.cpp @@ -321,14 +321,6 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator) Q_ASSERT(nRegisters == 0); registerOffset = bytecodeGenerator->currentRegister(); - if (contextType == ContextType::ESModule && !localNameForDefaultExport.isEmpty()) { - if (!members.contains(localNameForDefaultExport)) { - // allocate a local slot for the default export, to be used in - // CodeGen::visit(ExportDeclaration*). - locals.append(localNameForDefaultExport); - } - } - QVector localsInTDZ; const auto registerLocal = [this, &localsInTDZ](Context::MemberMap::iterator member) { if (member->isLexicallyScoped()) { @@ -383,6 +375,15 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator) locals.append(member.key()); } + if (contextType == ContextType::ESModule && !localNameForDefaultExport.isEmpty()) { + if (!members.contains(localNameForDefaultExport)) { + // allocate a local slot for the default export, to be used in + // CodeGen::visit(ExportDeclaration*). + locals.append(localNameForDefaultExport); + ++sizeOfLocalTemporalDeadZone; + } + } + sizeOfRegisterTemporalDeadZone = registersInTDZ.count(); firstTemporalDeadZoneRegister = bytecodeGenerator->currentRegister(); for (auto &member: qAsConst(registersInTDZ)) -- cgit v1.2.3