From a29ab499a4822014d34d6e9e988600fdb6d60a0d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 14 Aug 2018 15:43:19 +0200 Subject: Fix explicit export of imported variables Instead of using a re-export, it's also possible to write import { foo } from "./bar.js" and then export it again export { foo } Typically exported variables are referenced from the locals, but since we don't add imports to the locals, we need another way of locating them. This patch uses the index space after the locals in the internal class for imports, so that after we've identifier the export in the local export entry table, we can use the local name to search in the internal class and find imports past the locals. Change-Id: I58ab79ad3df1bbc1b972f0a2771d9ca1268de27b Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compileddata.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/qml/compiler/qv4compileddata.cpp') diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 52db3100fc..798bfe921e 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -469,9 +469,11 @@ const Value *CompilationUnit::resolveExportRecursively(QV4::String *exportName, if (auto localExport = lookupNameInExportTable(data->localExportEntryTable(), data->localExportEntryTableSize, exportName)) { ScopedString localName(scope, runtimeStrings[localExport->localName]); uint index = m_module->scope->internalClass->find(localName->toPropertyKey()); - if (index < UINT_MAX) - return &m_module->scope->locals[index]; - return nullptr; + if (index >= UINT_MAX) + return nullptr; + if (index >= m_module->scope->locals.size) + return imports[index - m_module->scope->locals.size]; + return &m_module->scope->locals[index]; } if (auto indirectExport = lookupNameInExportTable(data->indirectExportEntryTable(), data->indirectExportEntryTableSize, exportName)) { -- cgit v1.2.3