diff options
author | Moonchild <moonchild@palemoon.org> | 2020-07-04 23:12:13 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-07-10 18:31:06 +0000 |
commit | 83abc5af599d4531c68c2e7a84caab9545854594 (patch) | |
tree | 86f593eb6b8e2dc977ed8d132ffdb8cf98b0aebf /js/src/builtin/Module.js | |
parent | 47101f49c08b04c84029c1d05a9ee9a4b3ea921d (diff) | |
download | UXP-83abc5af599d4531c68c2e7a84caab9545854594.tar UXP-83abc5af599d4531c68c2e7a84caab9545854594.tar.gz UXP-83abc5af599d4531c68c2e7a84caab9545854594.tar.lz UXP-83abc5af599d4531c68c2e7a84caab9545854594.tar.xz UXP-83abc5af599d4531c68c2e7a84caab9545854594.zip |
Issue #618 - Report source position information (line/column)
Report source position information for module export resolution failures.
Ref: BZ 1362098
Diffstat (limited to 'js/src/builtin/Module.js')
-rw-r--r-- | js/src/builtin/Module.js | 37 |
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() |