summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-03-26 22:56:56 +0100
committerAraq <rumpf_a@web.de>2014-03-26 22:56:56 +0100
commitdc956c485aa9d8becd3d9eb3c2086ebac3b6eeed (patch)
treef757b71cc2ba4e32810b589d9cf513298a4e485e /compiler
parenta1e97ad4a4fef8004d833853828a4ea7da3958c3 (diff)
downloadNim-dc956c485aa9d8becd3d9eb3c2086ebac3b6eeed.tar.gz
fixes tmemit regression
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semtempl.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index 407da8bdb..b71198119 100644
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -232,6 +232,18 @@ proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind) =
     for j in countup(0, L-3):
       addLocalDecl(c, a.sons[j], symKind)
 
+proc onlyReplaceParams(c: var TemplCtx, n: PNode): PNode =
+  result = n
+  if n.kind == nkIdent:
+    let s = qualifiedLookUp(c.c, n, {})
+    if s != nil:
+      if s.owner == c.owner and s.kind == skParam:
+        incl(s.flags, sfUsed)
+        result = newSymNode(s, n.info)
+  else:
+    for i in 0 .. <n.safeLen:
+      result.sons[i] = onlyReplaceParams(c, n.sons[i])
+
 proc semPattern(c: PContext, n: PNode): PNode
 proc semTemplBody(c: var TemplCtx, n: PNode): PNode = 
   result = n
@@ -365,6 +377,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
     result.sons[0] = semTemplBody(c, n.sons[0])
   of nkPostfix:
     result.sons[1] = semTemplBody(c, n.sons[1])
+  of nkPragma:
+    result = onlyReplaceParams(c, n)
   else:
     # dotExpr is ambiguous: note that we explicitely allow 'x.TemplateParam',
     # so we use the generic code for nkDotExpr too