summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/Module.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/builtin/Module.js')
-rw-r--r--js/src/builtin/Module.js37
1 files changed, 21 insertions, 16 deletions
diff --git a/js/src/builtin/Module.js b/js/src/builtin/Module.js
index 064293670..b3365b505 100644
--- a/js/src/builtin/Module.js
+++ b/js/src/builtin/Module.js
@@ -436,8 +436,10 @@ function ModuleDeclarationEnvironmentSetup(module)
let resolution = callFunction(module.resolveExport, module, e.exportName);
assert(resolution.resolved || resolution.module,
"Unexpected failure to resolve export in ModuleDeclarationEnvironmentSetup");
- if (!resolution.resolved)
- return ResolutionError(resolution, "indirectExport", e.exportName)
+ if (!resolution.resolved) {
+ return ResolutionError(resolution, "indirectExport", e.exportName,
+ e.lineNumber, e.columnNumber)
+ }
}
// Steps 5-6
@@ -459,8 +461,10 @@ function ModuleDeclarationEnvironmentSetup(module)
if (!resolution.resolved && !resolution.module)
resolution.module = module;
- if (!resolution.resolved)
- return ResolutionError(resolution, "import", imp.importName);
+ if (!resolution.resolved) {
+ return ResolutionError(resolution, "import", imp.importName,
+ imp.lineNumber, imp.columnNumber);
+ }
CreateImportBinding(env, imp.localName, resolution.module, resolution.bindingName);
}
@@ -470,7 +474,7 @@ function ModuleDeclarationEnvironmentSetup(module)
}
// 15.2.1.16.4.3 ResolutionError(module)
-function ResolutionError(resolution, kind, name)
+function ResolutionError(resolution, kind, name, line, column)
{
let module = resolution.module;
assert(module !== null,
@@ -483,21 +487,22 @@ function ResolutionError(resolution, kind, name)
assert(kind === "import" || kind === "indirectExport",
"Unexpected kind in ResolutionError");
- let message;
+ assert(line > 0,
+ "Line number should be present for all imports and indirect exports");
+
+ let errorNumber;
if (kind === "import") {
- message = resolution.ambiguous ? JSMSG_AMBIGUOUS_IMPORT
- : JSMSG_MISSING_IMPORT;
+ errorNumber = resolution.ambiguous ? JSMSG_AMBIGUOUS_IMPORT
+ : JSMSG_MISSING_IMPORT;
} else {
- message = resolution.ambiguous ? JSMSG_AMBIGUOUS_INDIRECT_EXPORT
- : JSMSG_MISSING_INDIRECT_EXPORT;
+ errorNumber = resolution.ambiguous ? JSMSG_AMBIGUOUS_INDIRECT_EXPORT
+ : JSMSG_MISSING_INDIRECT_EXPORT;
}
- try {
- ThrowSyntaxError(message, name);
- } catch (error) {
- RecordModuleError(module, error);
- throw error;
- }
+ let message = GetErrorMessage(errorNumber) + ": " + name;
+ let error = CreateModuleSyntaxError(module, line, column, message);
+ RecordModuleError(module, error);
+ throw error;
}
// 15.2.1.16.5 ModuleEvaluate()