Do not allow self import

This commit is contained in:
Simon Krauter 2014-10-14 23:38:50 +02:00
commit 849484f920

View file

@ -159,6 +159,8 @@ proc myImportModule(c: PContext, n: PNode): PSym =
var f = checkModuleName(n) var f = checkModuleName(n)
if f != InvalidFileIDX: if f != InvalidFileIDX:
result = importModuleAs(n, gImportModule(c.module, f)) result = importModuleAs(n, gImportModule(c.module, f))
if result.name.s == fileInfos[n.info.fileIndex].shortName:
localError(n.info, errGenerated, "A module cannot import itself")
if sfDeprecated in result.flags: if sfDeprecated in result.flags:
message(n.info, warnDeprecated, result.name.s) message(n.info, warnDeprecated, result.name.s)