summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-02-21 18:46:50 +0800
committerGitHub <noreply@github.com>2023-02-21 11:46:50 +0100
commitbdc850916fb5d23fa4b9282309985e0fdfb0db36 (patch)
treec1b423a7743c5f145f52ca6472bdf1efcfb22e8a
parentffd6bc87495ede82f9a8086d38c3348a40b11672 (diff)
downloadNim-bdc850916fb5d23fa4b9282309985e0fdfb0db36.tar.gz
improve invalid module names errors (#21412)
I have seen these questions: "Why I got an invalid module name errors?". To eliminate this kind of questions, We might improve th error messages. Though, the question might evolve into "What is a valid Nim identifier", which should be more searchable on the Internet.
-rw-r--r--compiler/modules.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/modules.nim b/compiler/modules.nim
index 7f6ff8622..838a89d83 100644
--- a/compiler/modules.nim
+++ b/compiler/modules.nim
@@ -38,7 +38,8 @@ proc newModule(graph: ModuleGraph; fileIdx: FileIndex): PSym =
                 name: getModuleIdent(graph, filename),
                 info: newLineInfo(fileIdx, 1, 1))
   if not isNimIdentifier(result.name.s):
-    rawMessage(graph.config, errGenerated, "invalid module name: " & result.name.s)
+    rawMessage(graph.config, errGenerated, "invalid module name: '" & result.name.s &
+              "'; a module name must be a valid Nim identifier.")
   partialInitModule(result, graph, fileIdx, filename)
   graph.registerModule(result)