From d4ca7f779d85b01a7e650abefeb8cd6502eff8e2 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 15 Aug 2018 14:53:28 +0200 Subject: Fix initialization of default exported functions and generators When registering a default export, make sure that the local name points either to an entry that we've entered into the environment or the synthetic entry we create. Change-Id: I37e160dc1e3231214bb68f72d6bb0746d7aee3b3 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compilercontext.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/qml/compiler/qv4compilercontext.cpp') diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp index c0fbb72c59..09be19e427 100644 --- a/src/qml/compiler/qv4compilercontext.cpp +++ b/src/qml/compiler/qv4compilercontext.cpp @@ -295,9 +295,12 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator) Q_ASSERT(nRegisters == 0); registerOffset = bytecodeGenerator->currentRegister(); - if (contextType == ContextType::ESModule && hasDefaultExport) { - // allocate a local slot for the default export - locals.append(QStringLiteral("*default*")); + 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); + } } switch (contextType) { -- cgit v1.2.3