summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-05-12 16:14:46 +0300
committerZahary Karadjov <zahary@gmail.com>2013-05-12 16:14:46 +0300
commitfca6e31e1d14dc9a4ba902aa727a008f4fbbf71c (patch)
treec0393a58efc8d0e73939fa0f19dff03fe6e84795 /compiler
parent1d29d24465ddb9aaea18558f221ff67bf82db0c7 (diff)
parent37b5be0133815423f785d0779f839fc7f8e09999 (diff)
downloadNim-fca6e31e1d14dc9a4ba902aa727a008f4fbbf71c.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod into upstream
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sempass2.nim13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index 9213bd48d..b78e36531 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -79,6 +79,7 @@ type
     exc: PNode  # stack of exceptions
     tags: PNode # list of tags
     bottom: int
+    owner: PSym
   
   PEffects = var TEffects
 
@@ -173,11 +174,16 @@ proc trackTryStmt(tracked: PEffects, n: PNode) =
     track(tracked, b.sons[blen-1])
   tracked.bottom = oldBottom
 
-proc isIndirectCall(n: PNode): bool =
+proc isIndirectCall(n: PNode, owner: PSym): bool =
   # we don't count f(...) as an indirect call if 'f' is an parameter.
   # Instead we track expressions of type tyProc too. See the manual for
   # details:
-  result = n.kind != nkSym or n.sym.kind notin (routineKinds+{skParam})
+  if n.kind != nkSym: 
+    result = true
+  elif n.sym.kind == skParam:
+    result = owner != n.sym.owner or owner == nil
+  elif n.sym.kind notin routineKinds:
+    result = true
 
 proc isForwardedProc(n: PNode): bool =
   result = n.kind == nkSym and sfForward in n.sym.flags
@@ -274,7 +280,7 @@ proc track(tracked: PEffects, n: PNode) =
       elif effectList.len == 0:
         if isForwardedProc(a):
           propagateEffects(tracked, n, a.sym)
-        elif isIndirectCall(a):
+        elif isIndirectCall(a, tracked.owner):
           addEffect(tracked, createRaise(n))
           addTag(tracked, createTag(n))
       else:
@@ -355,6 +361,7 @@ proc trackProc*(s: PSym, body: PNode) =
   var t: TEffects
   t.exc = effects.sons[exceptionEffects]
   t.tags = effects.sons[tagEffects]
+  t.owner = s
   track(t, body)
   
   let p = s.ast.sons[pragmasPos]