aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilercontext.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-22 11:57:36 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-29 06:54:07 +0000
commit16f18f68e37661f45047c913b9e6f9068dbc88a9 (patch)
tree6710ac3fa656a3d8f7579a01ede6af8592d4b09a /src/qml/compiler/qv4compilercontext.cpp
parenta7fc82e2e95657e048e43fe438d07b63349c38cd (diff)
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilercontext.cpp')
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp17
1 files changed, 9 insertions, 8 deletions
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<Context::MemberMap::Iterator> 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))