summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-06-21 09:03:49 +0200
committerAraq <rumpf_a@web.de>2012-06-21 09:03:49 +0200
commit2294c02cc899d42695e659572e75d7f87680de2b (patch)
tree0fd560657492e8101f64244e3f26374be65897dc
parent7b4560337b3489ba2364fe97066c79d8a23dad87 (diff)
downloadNim-2294c02cc899d42695e659572e75d7f87680de2b.tar.gz
and another closure bugfix
-rw-r--r--compiler/lambdalifting.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index 2bf6ac57e..0052e178b 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -302,7 +302,7 @@ proc transformInnerProc(o: POuterContext, i: PInnerContext, n: PNode): PNode =
     let s = n.sym
     if s == i.fn: 
       # recursive calls go through (lambda, hiddenParam):
-      assert i.closureParam != nil
+      assert i.closureParam != nil, i.fn.name.s
       result = makeClosure(s, i.closureParam, n.info)
     elif isInnerProc(s, o.fn) and s.typ.callConv == ccClosure:
       # ugh: call to some other inner proc; 
@@ -340,8 +340,10 @@ proc searchForInnerProcs(o: POuterContext, n: PNode) =
       # dummy closure param needed?
       if inner.closureParam == nil and n.sym.typ.callConv == ccClosure:
         dummyClosureParam(o, inner)
-      let ti = transformInnerProc(o, inner, body)
-      if ti != nil: n.sym.ast.sons[bodyPos] = ti
+      # only transform if it really needs a closure:
+      if inner.closureParam != nil:
+        let ti = transformInnerProc(o, inner, body)
+        if ti != nil: n.sym.ast.sons[bodyPos] = ti
   of nkLambdaKinds:
     searchForInnerProcs(o, n.sons[namePos])
   of nkWhileStmt, nkForStmt, nkParForStmt, nkBlockStmt: