Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

much better error message for missing modules #562

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/nifreader.nim
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ proc open*(filename: string): Reader =
memfiles.open(filename)
except:
when defined(debug): writeStackTrace()
quit "cannot open: " & filename
quit "[Error] cannot open: " & filename
result = Reader(f: f, p: nil)
result.p = cast[pchar](result.f.mem)
result.eof = result.p +! result.f.size
Expand Down
8 changes: 4 additions & 4 deletions src/nimony/deps.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ proc exeFile(f: FilePair): string = "nifcache" / f.modname.addFileExt ExeExt

proc resolveFileWrapper(paths: openArray[string]; origin: string; toResolve: string): string =
result = resolveFile(paths, origin, toResolve)
if not fileExists(result) and toResolve.startsWith("std/"):
if not semos.fileExists(result) and toResolve.startsWith("std/"):
result = resolveFile(paths, origin, toResolve.substr(4))

type
Expand Down Expand Up @@ -94,7 +94,7 @@ proc processInclude(c: var DepContext; it: var Cursor; current: Node) =
isRecursive = true
break

if not isRecursive and fileExists(f2):
if not isRecursive and semos.fileExists(f2):
let oldActive = current.active
current.active = current.files.len
current.files.add c.toPair(f2)
Expand All @@ -116,7 +116,7 @@ proc wouldCreateCycle(c: var DepContext; current: Node; p: FilePair): bool =
proc importSingleFile(c: var DepContext; f1: string; info: PackedLineInfo;
current: Node; isSystem: bool) =
let f2 = resolveFileWrapper(c.config.paths, current.files[current.active].nimFile, f1)
if not fileExists(f2): return
if not semos.fileExists(f2): return
let p = c.toPair(f2)
if not c.processedModules.containsOrIncl(p.modname):
current.deps.add p
Expand Down Expand Up @@ -193,7 +193,7 @@ proc processDeps(c: var DepContext; n: Cursor; current: Node) =
processDep c, n, current

proc execNifler(c: var DepContext; input, output: string) =
if not c.forceRebuild and fileExists(output) and fileExists(input) and
if not c.forceRebuild and semos.fileExists(output) and semos.fileExists(input) and
getLastModificationTime(output) > getLastModificationTime(input):
discard "nothing to do"
else:
Expand Down
2 changes: 1 addition & 1 deletion src/nimony/nimsem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type
None, SingleModule

proc singleModule(infile, outfile, idxfile: string; config: sink NifConfig; moduleFlags: set[ModuleFlag]) =
if not fileExists(infile):
if not semos.fileExists(infile):
quit "cannot find " & infile
else:
semcheck(infile, outfile, ensureMove config, moduleFlags, "", false)
Expand Down
5 changes: 4 additions & 1 deletion src/nimony/sem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ type

proc importSingleFile(c: var SemContext; f1: ImportedFilename; origin: string; mode: ImportMode; info: PackedLineInfo) =
let f2 = resolveFile(c.g.config.paths, origin, f1.path)
if not fileExists(f2):
c.buildErr info, "file not found: " & f2
return
let suffix = moduleSuffix(f2, c.g.config.paths)
if not c.processedModules.containsOrIncl(suffix):
c.meta.importedFiles.add f2
Expand Down Expand Up @@ -5091,7 +5094,7 @@ proc semPragmaLine(c: var SemContext; it: var Item; info: PackedLineInfo) =
var name = replaceSubs(args[1], currentDir, c.g.config).toAbsolutePath(currentDir)
let customArgs = if args.len == 3: replaceSubs(args[2], currentDir, c.g.config) else: ""

if not fileExists2(name):
if not semos.fileExists(name):
buildErr c, it.n.info, "cannot find: " & name
name = name.toRelativePath(nifcacheDir)

Expand Down
2 changes: 1 addition & 1 deletion src/nimony/semos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ proc toolDir*(f: string): string =
proc absoluteParentDir*(f: string): string =
result = f.absolutePath().parentDir()

proc fileExists2*(f: string): bool =
proc fileExists*(f: string): bool =
result = os.fileExists(f)

proc toAbsolutePath*(f: string): string =
Expand Down
Loading