Skip to content

Commit

Permalink
Bug 1476921 - Don't throw an error in GetModuleNamespace for errored …
Browse files Browse the repository at this point in the history
…modules. r=jonco
  • Loading branch information
khyperia committed Aug 28, 2018
1 parent bd72b95 commit 905a4c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
13 changes: 4 additions & 9 deletions js/src/builtin/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,14 @@ function GetModuleNamespace(module)
// Step 1
assert(IsObject(module) && IsModule(module), "GetModuleNamespace called with non-module");

// Until issue https://github.com/tc39/ecma262/issues/1155 is resolved,
// violate the spec here and throw if called on an errored module.
if (module.status === MODULE_STATUS_EVALUATED_ERROR)
throw GetModuleEvaluationError(module);

// Steps 2-3
// Step 2
assert(module.status !== MODULE_STATUS_UNINSTANTIATED,
"Bad module state in GetModuleNamespace");

// Step 4
// Step 3
let namespace = module.namespace;

// Step 3
// Step 4
if (typeof namespace === "undefined") {
let exportedNames = callFunction(module.getExportedNames, module);
let unambiguousNames = new_List();
Expand All @@ -213,7 +208,7 @@ function GetModuleNamespace(module)
namespace = ModuleNamespaceCreate(module, unambiguousNames);
}

// Step 4
// Step 5
return namespace;
}

Expand Down
19 changes: 19 additions & 0 deletions js/src/jit-test/tests/modules/bug-1476921.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

load(libdir + "asserts.js");
load(libdir + "dummyModuleResolveHook.js");

class UniqueError extends Error {}

let a = moduleRepo['a'] = parseModule(`
throw new UniqueError();
`);

let b = moduleRepo['b'] = parseModule(`
import * as ns0 from "a";
`);

a.declarationInstantiation();
assertThrowsInstanceOf(() => a.evaluation(), UniqueError);
b.declarationInstantiation();
assertThrowsInstanceOf(() => b.evaluation(), UniqueError);
3 changes: 2 additions & 1 deletion js/src/jit-test/tests/modules/bug1449153.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ assertThrowsMyError(() => c.evaluation());
let b = moduleRepo['b'] = parseModule(`
import * as ns0 from 'a'
`);
assertThrowsMyError(() => b.declarationInstantiation());
b.declarationInstantiation();
assertThrowsMyError(() => b.evaluation(b));

0 comments on commit 905a4c8

Please sign in to comment.