summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2016-01-18 13:48:58 +0100
committerAraq <rumpf_a@web.de>2016-01-18 13:48:58 +0100
commit38da21fc62381fefe8f9e957fb0144cda4e7903a (patch)
tree52f15076071e8eca4d146ecfec260d1d1b1423aa /compiler
parent55c1f3d30ce5d2ab8745ab2b98a38a605c690a54 (diff)
downloadNim-38da21fc62381fefe8f9e957fb0144cda4e7903a.tar.gz
fixes #3730
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim2
-rw-r--r--compiler/lambdalifting.nim8
-rw-r--r--compiler/transf.nim4
3 files changed, 11 insertions, 3 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 6f513c165..3607f347e 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1847,6 +1847,8 @@ proc genClosure(p: BProc, n: PNode, d: var TLoc) =
     var tmp, a, b: TLoc
     initLocExpr(p, n.sons[0], a)
     initLocExpr(p, n.sons[1], b)
+    if n.sons[0].skipConv.kind == nkClosure:
+      internalError(n.info, "closure to closure created")
     getTemp(p, n.typ, tmp)
     linefmt(p, cpsStmts, "$1.ClPrc = $2; $1.ClEnv = $3;$n",
             tmp.rdLoc, a.rdLoc, b.rdLoc)
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index 9265d09e3..1c0c2494a 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -213,7 +213,7 @@ proc makeClosure*(prc: PSym; env: PNode; info: TLineInfo): PNode =
   if env == nil:
     result.add(newNodeIT(nkNilLit, info, getSysType(tyNil)))
   else:
-    if env.kind == nkClosure:
+    if env.skipConv.kind == nkClosure:
       localError(info, "internal error: taking closure of closure")
     result.add(env)
 
@@ -711,7 +711,11 @@ proc liftCapturedVars(n: PNode; owner: PSym; d: DetectionPass;
   of nkClosure:
     if n[1].kind == nkNilLit:
       n.sons[0] = liftCapturedVars(n[0], owner, d, c)
-      #if n.sons[0].kind == nkClosure: result = n.sons[0]
+      let x = n.sons[0].skipConv
+      if x.kind == nkClosure:
+        #localError(n.info, "internal error: closure to closure created")
+        # now we know better, so patch it:
+        n.sons[0] = x.sons[0]
   of nkLambdaKinds, nkIteratorDef:
     if n.typ != nil and n[namePos].kind == nkSym:
       let m = newSymNode(n[namePos].sym)
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 3e074841e..b2bbdcec3 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -383,9 +383,11 @@ proc generateThunk(prc: PNode, dest: PType): PNode =
   # (see internal documentation):
   if gCmd == cmdCompileToJS: return prc
   result = newNodeIT(nkClosure, prc.info, dest)
-  var conv = newNodeIT(nkHiddenStdConv, prc.info, dest)
+  var conv = newNodeIT(nkHiddenSubConv, prc.info, dest)
   conv.add(emptyNode)
   conv.add(prc)
+  if prc.kind == nkClosure:
+    internalError(prc.info, "closure to closure created")
   result.add(conv)
   result.add(newNodeIT(nkNilLit, prc.info, getSysType(tyNil)))