diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 55a58c7f04e4c..b1cf1a6cb7619 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -994,18 +994,18 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode, let callee = result[0].sym case callee.kind of skMacro, skTemplate: discard - else: - if callee.kind == skIterator and callee.id == c.p.owner.id and - not isClosureIterator(c.p.owner.typ): + of skIterator: + if callee.id == c.p.owner.id and not isClosureIterator(c.p.owner.typ): localError(c.config, n.info, errRecursiveDependencyIteratorX % callee.name.s) # error correction, prevents endless for loop elimination in transf. # See bug #2051: result[0] = newSymNode(errorSym(c, n)) - elif callee.kind == skIterator: - if efWantIterable in flags: - let typ = newTypeS(tyIterable, c) - rawAddSon(typ, result.typ) - result.typ() = typ + elif efWantIterable in flags: + let typ = newTypeS(tyIterable, c) + rawAddSon(typ, result.typ) + result.typ() = typ + else: + discard proc resolveIndirectCall(c: PContext; n, nOrig: PNode; t: PType): TCandidate = @@ -1075,6 +1075,16 @@ proc afterCallActions(c: PContext; n, orig: PNode, flags: TExprFlags; expectedTy # don't fold calls in concepts and typeof result = evalAtCompileTime(c, result) +proc normalizeMethodCallSyntax(n: PNode): PNode = + # transforms A.b(C) to b(A, C) + # does not check if `b` is a field + result = n[0] + result.transitionSonsKind(nkCall) + for i in 1..