From 338683a1980e32fb31d8a09e0308e422b883e686 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 22 Nov 2012 01:36:57 +0100 Subject: [PATCH] bugfixes for thread analysis --- compiler/semthreads.nim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/semthreads.nim b/compiler/semthreads.nim index 6c0259ef11..75621be79f 100755 --- a/compiler/semthreads.nim +++ b/compiler/semthreads.nim @@ -184,8 +184,9 @@ proc analyseCall(c: PProcCtx, n: PNode): TThreadOwner = call.args[i-1] = analyse(c, n[i]) if not computed.hasKey(call): computed[call] = toUndefined # we are computing it - for i in 1..n.len-1: - var formal = skipTypes(prc.typ, abstractInst).n.sons[i].sym + let prctyp = skipTypes(prc.typ, abstractInst).n + for i in 1.. prctyp.len-1: + var formal = prctyp.sons[i].sym newCtx.mapping[formal.id] = call.args[i-1] pushInfoContext(n.info) result = analyse(newCtx, prc.getBody) @@ -226,7 +227,8 @@ proc analyseVarSection(c: PProcCtx, n: PNode): TThreadOwner = var a = n.sons[i] if a.kind == nkCommentStmt: continue if a.kind == nkIdentDefs: - assert(a.sons[0].kind == nkSym) + #assert(a.sons[0].kind == nkSym); also valid for after + # closure transformation: analyseSingleVar(c, a) else: analyseVarTuple(c, a) @@ -359,9 +361,11 @@ proc analyse(c: PProcCtx, n: PNode): TThreadOwner = of nkReturnStmt, nkDiscardStmt: if n.sons[0].kind != nkEmpty: result = analyse(c, n.sons[0]) else: result = toVoid + of nkLambdaKinds, nkClosure: + result = toMine of nkAsmStmt, nkPragma, nkIteratorDef, nkProcDef, nkMethodDef, - nkConverterDef, nkMacroDef, nkTemplateDef, nkLambdaKinds, nkClosure, - nkGotoState, nkState: + nkConverterDef, nkMacroDef, nkTemplateDef, + nkGotoState, nkState, nkBreakState, nkType: result = toVoid of nkExprColonExpr: result = analyse(c, n.sons[1])