From dc45b495a7912ee241f9d8cfbf177d574341adbb Mon Sep 17 00:00:00 2001 From: dcode Date: Tue, 22 Mar 2022 05:17:22 +0100 Subject: [PATCH] Emit a diagnostic when a --use element cannot be found --- src/diagnosticMessages.json | 1 + src/program.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/diagnosticMessages.json b/src/diagnosticMessages.json index 5ff99ccc9e..5c9a03e6f2 100644 --- a/src/diagnosticMessages.json +++ b/src/diagnosticMessages.json @@ -10,6 +10,7 @@ "Shared memory requires feature 'threads' to be enabled.": 108, "Transform '{0}': {1}": 109, "Start function name '{0}' is invalid or conflicts with another export.": 110, + "Element '{0}' not found.": 111, "Conversion from type '{0}' to '{1}' requires an explicit cast.": 200, "Conversion from type '{0}' to '{1}' will require an explicit cast when switching between 32/64-bit.": 201, diff --git a/src/program.ts b/src/program.ts index 6bb1dea523..4e28ba2478 100644 --- a/src/program.ts +++ b/src/program.ts @@ -1421,7 +1421,7 @@ export class Program extends DiagnosticEmitter { if (elementsByName.has(name)) { elementsByName.set(alias, assert(elementsByName.get(name))); } else { - throw new Error("no such global element: " + name); + this.error(DiagnosticCode.Element_0_not_found, null, name); } } }