summary refs log tree commit diff stats
path: root/compiler/semtempl.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semtempl.nim')
-rwxr-xr-xcompiler/semtempl.nim24
1 files changed, 12 insertions, 12 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index 770a3ae8e..2600d80cb 100755
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -7,6 +7,8 @@
 #    distribution, for details about the copyright.
 #
 
+# included from sem.nim
+
 proc isExpr(n: PNode): bool = 
   # returns true if ``n`` looks like an expression
   case n.kind
@@ -54,11 +56,6 @@ proc evalTemplateArgs(c: PContext, n: PNode, s: PSym): PNode =
     else: arg = copyTree(s.typ.n.sons[i].sym.ast)
     if arg == nil or arg.kind == nkEmpty: 
       LocalError(n.info, errWrongNumberOfArguments)
-    elif not (s.typ.sons[i].kind in {tyTypeDesc, tyStmt, tyExpr}): 
-      # concrete type means semantic checking for argument:
-      # XXX This is horrible! Better make semantic checking use some kind
-      # of fixpoint iteration ...
-      arg = fitNode(c, s.typ.sons[i], semExprWithType(c, arg))
     addSon(result, arg)
 
 proc evalTemplate*(c: PContext, n: PNode, sym: PSym): PNode = 
@@ -167,9 +164,9 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
   # check parameter list:
   pushOwner(s)
   openScope(c.tab)
-  n.sons[namePos] = newSymNode(s) # check that no pragmas exist:
-  if n.sons[pragmasPos].kind != nkEmpty: 
-    LocalError(n.info, errNoPragmasAllowedForX, "template") 
+  n.sons[namePos] = newSymNode(s)
+  if n.sons[pragmasPos].kind != nkEmpty:
+    pragma(c, s, n.sons[pragmasPos], templatePragmas)
   # check that no generic parameters exist:
   if n.sons[genericParamsPos].kind != nkEmpty: 
     LocalError(n.info, errNoGenericParamsAllowedForX, "template")
@@ -185,8 +182,6 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
       # use ``stmt`` as implicit result type
       s.typ.sons[0] = newTypeS(tyStmt, c)
       s.typ.n.sons[0] = newNodeIT(nkType, n.info, s.typ.sons[0])
-  # XXX: obsoleted - happens in semParamList # 
-  # addParams(c, s.typ.n)       # resolve parameters:
   var toBind = initIntSet()
   n.sons[bodyPos] = resolveTemplateParams(c, n.sons[bodyPos], false, toBind)
   if s.typ.sons[0].kind notin {tyStmt, tyTypeDesc}:
@@ -198,5 +193,10 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
   result = n
   if n.sons[bodyPos].kind == nkEmpty: 
     LocalError(n.info, errImplOfXexpected, s.name.s)
-  # add identifier of template as a last step to not allow recursive templates:
-  addInterfaceDecl(c, s)
+  let curScope = c.tab.tos - 1
+  var proto = SearchForProc(c, s, curScope)
+  if proto == nil:
+    addInterfaceOverloadableSymAt(c, s, curScope)
+  else:
+    SymTabReplace(c.tab.stack[curScope], proto, s)
+