This commit is contained in:
Andreas Rumpf 2017-01-06 18:15:08 +01:00
commit 64912d3d70
2 changed files with 5 additions and 4 deletions

View file

@ -49,11 +49,12 @@ proc getModuleName*(n: PNode): string =
localError(n.info, errGenerated, "invalid module name: '$1'" % n.renderTree) localError(n.info, errGenerated, "invalid module name: '$1'" % n.renderTree)
result = "" result = ""
proc checkModuleName*(n: PNode): int32 = proc checkModuleName*(n: PNode; doLocalError=true): int32 =
# This returns the full canonical path for a given module import # This returns the full canonical path for a given module import
let modulename = n.getModuleName let modulename = n.getModuleName
let fullPath = findModule(modulename, n.info.toFullPath) let fullPath = findModule(modulename, n.info.toFullPath)
if fullPath.len == 0: if fullPath.len == 0:
if doLocalError:
localError(n.info, errCannotOpenFile, modulename) localError(n.info, errCannotOpenFile, modulename)
result = InvalidFileIDX result = InvalidFileIDX
else: else:

View file

@ -440,11 +440,11 @@ proc isImportSystemStmt(n: PNode): bool =
case n.kind case n.kind
of nkImportStmt: of nkImportStmt:
for x in n: for x in n:
let f = checkModuleName(x) let f = checkModuleName(x, false)
if f == magicsys.systemModule.info.fileIndex: if f == magicsys.systemModule.info.fileIndex:
return true return true
of nkImportExceptStmt, nkFromStmt: of nkImportExceptStmt, nkFromStmt:
let f = checkModuleName(n[0]) let f = checkModuleName(n[0], false)
if f == magicsys.systemModule.info.fileIndex: if f == magicsys.systemModule.info.fileIndex:
return true return true
else: discard else: discard