diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-07-30 16:34:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-30 16:34:21 +0200 |
commit | fc9c40bafa8d9b5538f75c31403e89b122c32ff1 (patch) | |
tree | 931c8207195377814d4da642fc1e8ef0fe40ccf1 /compiler | |
parent | 2694aecfb886cfd6d7208d1dbc2175e4e1d852f4 (diff) | |
parent | 2bea2bdbbf0b709811203f64d07ba6ddf3e90cc7 (diff) | |
download | Nim-fc9c40bafa8d9b5538f75c31403e89b122c32ff1.tar.gz |
Merge pull request #4542 from kierdavis/4541-import-error
Fix #4541
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/importer.nim | 6 | ||||
-rw-r--r-- | compiler/lookups.nim | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index 5ffe12728..dd2c4d954 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -176,7 +176,7 @@ proc evalImport(c: PContext, n: PNode): PNode = var m = myImportModule(c, n.sons[i]) if m != nil: # ``addDecl`` needs to be done before ``importAllSymbols``! - addDecl(c, m) # add symbol to symbol table of module + addDecl(c, m, n.info) # add symbol to symbol table of module importAllSymbolsExcept(c, m, emptySet) #importForwarded(c, m.ast, emptySet) @@ -186,7 +186,7 @@ proc evalFrom(c: PContext, n: PNode): PNode = var m = myImportModule(c, n.sons[0]) if m != nil: n.sons[0] = newSymNode(m) - addDecl(c, m) # add symbol to symbol table of module + addDecl(c, m, n.info) # add symbol to symbol table of module for i in countup(1, sonsLen(n) - 1): if n.sons[i].kind != nkNilLit: importSymbol(c, n.sons[i], m) @@ -197,7 +197,7 @@ proc evalImportExcept*(c: PContext, n: PNode): PNode = var m = myImportModule(c, n.sons[0]) if m != nil: n.sons[0] = newSymNode(m) - addDecl(c, m) # add symbol to symbol table of module + addDecl(c, m, n.info) # add symbol to symbol table of module var exceptSet = initIntSet() for i in countup(1, sonsLen(n) - 1): let ident = lookups.considerQuotedIdent(n.sons[i]) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index ba2358b86..de43c4e4a 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -162,6 +162,10 @@ proc wrongRedefinition*(info: TLineInfo, s: string) = if gCmd != cmdInteractive: localError(info, errAttemptToRedefine, s) +proc addDecl*(c: PContext, sym: PSym, info: TLineInfo) = + if not c.currentScope.addUniqueSym(sym): + wrongRedefinition(info, sym.name.s) + proc addDecl*(c: PContext, sym: PSym) = if not c.currentScope.addUniqueSym(sym): wrongRedefinition(sym.info, sym.name.s) |