diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-14 09:02:03 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-14 09:02:03 +0200 |
commit | ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef (patch) | |
tree | 7b00445d8b93410c684c0181b18a7e85c1a3cb7b /js/src/builtin | |
parent | 8af513a2072d7f808f03a44b32130ff6ffcd7daa (diff) | |
download | UXP-ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef.tar UXP-ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef.tar.gz UXP-ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef.tar.lz UXP-ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef.tar.xz UXP-ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef.zip |
Bug 1341298 - Relax expected module state when resolving modules and circular module dependencies are present
Diffstat (limited to 'js/src/builtin')
-rw-r--r-- | js/src/builtin/Module.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/js/src/builtin/Module.js b/js/src/builtin/Module.js index 95f97495d..5c3d5e147 100644 --- a/js/src/builtin/Module.js +++ b/js/src/builtin/Module.js @@ -100,7 +100,7 @@ function ModuleResolveExport(exportName, resolveSet = []) let e = indirectExportEntries[i]; if (exportName === e.exportName) { let importedModule = CallModuleResolveHook(module, e.moduleRequest, - MODULE_STATE_INSTANTIATED); + MODULE_STATE_PARSED); return callFunction(importedModule.resolveExport, importedModule, e.importName, resolveSet); } @@ -120,7 +120,7 @@ function ModuleResolveExport(exportName, resolveSet = []) for (let i = 0; i < starExportEntries.length; i++) { let e = starExportEntries[i]; let importedModule = CallModuleResolveHook(module, e.moduleRequest, - MODULE_STATE_INSTANTIATED); + MODULE_STATE_PARSED); let resolution = callFunction(importedModule.resolveExport, importedModule, exportName, resolveSet); if (resolution === "ambiguous") @@ -205,8 +205,8 @@ function GetModuleEnvironment(module) function RecordInstantationFailure(module) { - // Set the module's environment slot to 'null' to indicate a failed module - // instantiation. + // Set the module's state to 'failed' to indicate a failed module + // instantiation and reset the environment slot to 'undefined'. assert(IsModule(module), "Non-module passed to RecordInstantationFailure"); SetModuleState(module, MODULE_STATE_FAILED); UnsafeSetReservedSlot(module, MODULE_OBJECT_ENVIRONMENT_SLOT, undefined); @@ -267,6 +267,8 @@ function ModuleDeclarationInstantiation() ThrowSyntaxError(JSMSG_MISSING_IMPORT, imp.importName); if (resolution === "ambiguous") ThrowSyntaxError(JSMSG_AMBIGUOUS_IMPORT, imp.importName); + if (resolution.module.state < MODULE_STATE_INSTANTIATED) + ThrowInternalError(JSMSG_BAD_MODULE_STATE); CreateImportBinding(env, imp.localName, resolution.module, resolution.bindingName); } } |