fixes #3730
This commit is contained in:
parent
55c1f3d30c
commit
38da21fc62
3 changed files with 11 additions and 3 deletions
|
|
@ -1847,6 +1847,8 @@ proc genClosure(p: BProc, n: PNode, d: var TLoc) =
|
||||||
var tmp, a, b: TLoc
|
var tmp, a, b: TLoc
|
||||||
initLocExpr(p, n.sons[0], a)
|
initLocExpr(p, n.sons[0], a)
|
||||||
initLocExpr(p, n.sons[1], b)
|
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)
|
getTemp(p, n.typ, tmp)
|
||||||
linefmt(p, cpsStmts, "$1.ClPrc = $2; $1.ClEnv = $3;$n",
|
linefmt(p, cpsStmts, "$1.ClPrc = $2; $1.ClEnv = $3;$n",
|
||||||
tmp.rdLoc, a.rdLoc, b.rdLoc)
|
tmp.rdLoc, a.rdLoc, b.rdLoc)
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ proc makeClosure*(prc: PSym; env: PNode; info: TLineInfo): PNode =
|
||||||
if env == nil:
|
if env == nil:
|
||||||
result.add(newNodeIT(nkNilLit, info, getSysType(tyNil)))
|
result.add(newNodeIT(nkNilLit, info, getSysType(tyNil)))
|
||||||
else:
|
else:
|
||||||
if env.kind == nkClosure:
|
if env.skipConv.kind == nkClosure:
|
||||||
localError(info, "internal error: taking closure of closure")
|
localError(info, "internal error: taking closure of closure")
|
||||||
result.add(env)
|
result.add(env)
|
||||||
|
|
||||||
|
|
@ -711,7 +711,11 @@ proc liftCapturedVars(n: PNode; owner: PSym; d: DetectionPass;
|
||||||
of nkClosure:
|
of nkClosure:
|
||||||
if n[1].kind == nkNilLit:
|
if n[1].kind == nkNilLit:
|
||||||
n.sons[0] = liftCapturedVars(n[0], owner, d, c)
|
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:
|
of nkLambdaKinds, nkIteratorDef:
|
||||||
if n.typ != nil and n[namePos].kind == nkSym:
|
if n.typ != nil and n[namePos].kind == nkSym:
|
||||||
let m = newSymNode(n[namePos].sym)
|
let m = newSymNode(n[namePos].sym)
|
||||||
|
|
|
||||||
|
|
@ -383,9 +383,11 @@ proc generateThunk(prc: PNode, dest: PType): PNode =
|
||||||
# (see internal documentation):
|
# (see internal documentation):
|
||||||
if gCmd == cmdCompileToJS: return prc
|
if gCmd == cmdCompileToJS: return prc
|
||||||
result = newNodeIT(nkClosure, prc.info, dest)
|
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(emptyNode)
|
||||||
conv.add(prc)
|
conv.add(prc)
|
||||||
|
if prc.kind == nkClosure:
|
||||||
|
internalError(prc.info, "closure to closure created")
|
||||||
result.add(conv)
|
result.add(conv)
|
||||||
result.add(newNodeIT(nkNilLit, prc.info, getSysType(tyNil)))
|
result.add(newNodeIT(nkNilLit, prc.info, getSysType(tyNil)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue