diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index bce766626..da64df9dc 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -756,6 +756,9 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode, else: if callee.kind in skIterators and callee.id == c.p.owner.id: localError(n.info, errRecursiveDependencyX, callee.name.s) + # error correction, prevents endless for loop elimination in transf. + # See bug #2051: + result.sons[0] = newSymNode(errorSym(c, n)) if sfNoSideEffect notin callee.flags: if {sfImportc, sfSideEffect} * callee.flags != {}: incl(c.p.owner.flags, sfSideEffect) diff --git a/compiler/transf.nim b/compiler/transf.nim index cf13630fd..2f520aa20 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -492,7 +492,8 @@ proc transformFor(c: PTransf, n: PNode): PTransNode = var newC = newTransCon(getCurrOwner(c)) newC.forStmt = n newC.forLoopBody = loopBody - internalAssert iter.kind == skIterator + # this can fail for 'nimsuggest' and 'check': + if iter.kind != skIterator: return result # generate access statements for the parameters (unless they are constant) pushTransCon(c, newC) for i in countup(1, sonsLen(call) - 1): diff --git a/doc/tut2.txt b/doc/tut2.txt index e92c7d2ad..4d30b1445 100644 --- a/doc/tut2.txt +++ b/doc/tut2.txt @@ -735,14 +735,6 @@ regular expressions: return tkUnknown -Term rewriting macros ---------------------- - -Term rewriting macros can be used to enhance the compilation process -with user defined optimizations; see this `document `_ for -further information. - - Building your first macro ------------------------- diff --git a/lib/system.nim b/lib/system.nim index a71699cae..f89f407f0 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1455,7 +1455,8 @@ template `>%` *(x, y: expr): expr {.immediate.} = y <% x proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.} ## The stringify operator for an integer argument. Returns `x` - ## converted to a decimal string. + ## converted to a decimal string. ``$`` is Nim's general way of + ## spelling `toString`:idx:. proc `$`*(x: int64): string {.magic: "Int64ToStr", noSideEffect.} ## The stringify operator for an integer argument. Returns `x` diff --git a/lib/system/repr.nim b/lib/system/repr.nim index 5a243cb44..f1029ff6a 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -30,14 +30,16 @@ proc reprStrAux(result: var string, s: string) = add result, "nil" return add result, reprPointer(cast[pointer](s)) & "\"" - for c in items(s): + for i in 0..