summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-03-17 20:43:31 +0100
committerAraq <rumpf_a@web.de>2013-03-17 20:43:31 +0100
commit3620155d937bb5d3ffe79ca9a62e4552ed7bca1b (patch)
treea5b0cd4c88a0d6c861a852154cd2e42238da26e9 /compiler
parent6ed18a8b2488821df057d38fabb1d7cd921d97e7 (diff)
downloadNim-3620155d937bb5d3ffe79ca9a62e4552ed7bca1b.tar.gz
bugfix: subtle bug about 'var' parameters in templates
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 0fd117132..2cc0de371 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -487,7 +487,7 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode =
       if n.sons[0].kind == nkSym: incl(n.sons[0].sym.flags, sfAddrTaken)
       result = newHiddenAddrTaken(c, n)
   else: 
-    result = newHiddenAddrTaken(c, n) # BUGFIX!
+    result = newHiddenAddrTaken(c, n)
   
 proc analyseIfAddressTakenInCall(c: PContext, n: PNode) = 
   checkMinSonsLen(n, 1)
@@ -502,16 +502,19 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
 
   if n.sons[0].kind == nkSym and n.sons[0].sym.magic in FakeVarParams: 
     # BUGFIX: check for L-Value still needs to be done for the arguments!
+    # note sometimes this is eval'ed twice so we check for nkHiddenAddr here:
     for i in countup(1, sonsLen(n) - 1): 
       if i < sonsLen(t) and t.sons[i] != nil and
           skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar: 
         if isAssignable(c, n.sons[i]) notin {arLValue, arLocalLValue}: 
-          LocalError(n.sons[i].info, errVarForOutParamNeeded)
+          if n.sons[i].kind != nkHiddenAddr:
+            LocalError(n.sons[i].info, errVarForOutParamNeeded)
     return
-  for i in countup(1, sonsLen(n) - 1): 
+  for i in countup(1, sonsLen(n) - 1):
     if i < sonsLen(t) and
         skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
-      n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
+      if n.sons[i].kind != nkHiddenAddr:
+        n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
   
 include semmagic