diff --git a/compiler/sem/semstmts.nim b/compiler/sem/semstmts.nim index 5acc11c8df9..00ad6c8901a 100644 --- a/compiler/sem/semstmts.nim +++ b/compiler/sem/semstmts.nim @@ -2182,45 +2182,52 @@ proc semProcAnnotation(c: PContext, prc: PNode): PNode = proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode {.nosinks.} = ## used for resolving 'auto' in lambdas based on their callsite addInNimDebugUtils(c.config, "semInferredLambda", n, result) - var n = n let original = n[namePos].sym let s = original #copySym(original, false) #incl(s.flags, sfFromGeneric) #s.owner = original - n = instantiateTypesInBody(c, pt, n, original) - result = n + result = instantiateTypesInBody(c, pt, n, original) s.ast = result - n[namePos].sym = s - n[genericParamsPos] = c.graph.emptyNode + result[namePos].sym = s + result[genericParamsPos] = c.graph.emptyNode # for LL we need to avoid wrong aliasing - n[paramsPos] = newNodeI(nkFormalParams, n[paramsPos].info, n.typ.n.len) - for i, p in n.typ.n.pairs: - n[paramsPos][i] = + result[paramsPos] = newNodeI(nkFormalParams, result[paramsPos].info, + result.typ.n.len) + for i, p in result.typ.n.pairs: + result[paramsPos][i] = case i of 0: # return type - newNodeIT(nkType, n.info, n.typ[0]) + newNodeIT(nkType, n.info, result.typ[0]) else: # copy instantiated parameters - n.typ.n[i] - s.typ = n.typ - let params = n.typ.n - for i in 1..