mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
fixes #5185
This commit is contained in:
@@ -49,12 +49,13 @@ proc getModuleName*(n: PNode): string =
|
||||
localError(n.info, errGenerated, "invalid module name: '$1'" % n.renderTree)
|
||||
result = ""
|
||||
|
||||
proc checkModuleName*(n: PNode): int32 =
|
||||
proc checkModuleName*(n: PNode; doLocalError=true): int32 =
|
||||
# This returns the full canonical path for a given module import
|
||||
let modulename = n.getModuleName
|
||||
let fullPath = findModule(modulename, n.info.toFullPath)
|
||||
if fullPath.len == 0:
|
||||
localError(n.info, errCannotOpenFile, modulename)
|
||||
if doLocalError:
|
||||
localError(n.info, errCannotOpenFile, modulename)
|
||||
result = InvalidFileIDX
|
||||
else:
|
||||
result = fullPath.fileInfoIdx
|
||||
|
||||
@@ -440,11 +440,11 @@ proc isImportSystemStmt(n: PNode): bool =
|
||||
case n.kind
|
||||
of nkImportStmt:
|
||||
for x in n:
|
||||
let f = checkModuleName(x)
|
||||
let f = checkModuleName(x, false)
|
||||
if f == magicsys.systemModule.info.fileIndex:
|
||||
return true
|
||||
of nkImportExceptStmt, nkFromStmt:
|
||||
let f = checkModuleName(n[0])
|
||||
let f = checkModuleName(n[0], false)
|
||||
if f == magicsys.systemModule.info.fileIndex:
|
||||
return true
|
||||
else: discard
|
||||
|
||||
Reference in New Issue
Block a user