fix for template redefinition. test cases added.

This commit is contained in:
Zahary Karadjov 2012-03-15 14:15:37 +02:00
commit 6975ba401b
8 changed files with 99 additions and 15 deletions

View file

@ -191,14 +191,10 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
result = n
if n.sons[bodyPos].kind == nkEmpty:
LocalError(n.info, errImplOfXexpected, s.name.s)
var proto = SearchForProc(c, s, c.tab.tos-2) # -2 because we have a scope
# open for parameters
let curScope = c.tab.tos - 2 # -2 because we have a scope open for parameters
var proto = SearchForProc(c, s, curScope)
if proto == nil:
# add identifier of template as a last step to not allow recursive templates:
addInterfaceOverloadableSymAt(c, s, c.tab.tos - 2)
else:
# overwrite template
proto.info = s.info
proto.ast = s.ast
proto.typ = s.typ
proto.flags = s.flags
SymTabReplace(c.tab.stack[curScope], proto, s)