diff options
author | Simon Krauter <krauter.simon@arcor.de> | 2014-10-14 23:38:50 +0200 |
---|---|---|
committer | Simon Krauter <krauter.simon@arcor.de> | 2014-10-14 23:38:50 +0200 |
commit | 849484f9202c66567a8e6937198498ef8a75f558 (patch) | |
tree | 6d29937a49ee29abdc0794a9873e19e1e0cf5a09 /compiler | |
parent | b7befd69ba0051c1db44a37c8c3e06c48990a9b1 (diff) | |
download | Nim-849484f9202c66567a8e6937198498ef8a75f558.tar.gz |
Do not allow self import
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/importer.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index b4cae017e..4a0d83c66 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -92,7 +92,7 @@ proc rawImportSymbol(c: PContext, s: PSym) = if s.kind == skConverter: addConverter(c, s) if hasPattern(s): addPattern(c, s) -proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = +proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = let ident = lookups.considerQuotedIdent(n) let s = strTableGet(fromMod.tab, ident) if s == nil: @@ -155,10 +155,12 @@ proc importModuleAs(n: PNode, realModule: PSym): PSym = # some misguided guy will write 'import abc.foo as foo' ... result = createModuleAlias(realModule, n.sons[1].ident, n.sons[1].info) -proc myImportModule(c: PContext, n: PNode): PSym = +proc myImportModule(c: PContext, n: PNode): PSym = var f = checkModuleName(n) if f != InvalidFileIDX: 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: message(n.info, warnDeprecated, result.name.s) |