More specific error message for unsupported recursion in iterators (#11283)

This commit is contained in:
Ico Doornekamp
2019-05-20 15:22:42 +02:00
committed by Andreas Rumpf
parent aeb6ec27de
commit c01f7bfdaf
3 changed files with 3 additions and 2 deletions

View File

@@ -804,7 +804,7 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
of skMacro, skTemplate: discard
else:
if callee.kind == skIterator and callee.id == c.p.owner.id:
localError(c.config, n.info, errRecursiveDependencyX % callee.name.s)
localError(c.config, n.info, errRecursiveDependencyIteratorX % callee.name.s)
# error correction, prevents endless for loop elimination in transf.
# See bug #2051:
result.sons[0] = newSymNode(errorSym(c, n))

View File

@@ -34,6 +34,7 @@ const
errThreadvarCannotInit = "a thread var cannot be initialized explicitly; this would only run for the main thread"
errImplOfXexpected = "implementation of '$1' expected"
errRecursiveDependencyX = "recursive dependency: '$1'"
errRecursiveDependencyIteratorX = "recursion is not supported in iterators: '$1'"
errPragmaOnlyInHeaderOfProcX = "pragmas are only allowed in the header of a proc; redefinition of $1"
errCannotAssignMacroSymbol = "cannot assign macro symbol to $1 here. Forgot to invoke the macro with '()'?"
errInvalidTypeDescAssign = "'typedesc' metatype is not valid here; typed '=' instead of ':'?"

View File

@@ -1,5 +1,5 @@
discard """
errormsg: "recursive dependency: \'myrec\'"
errormsg: "recursion is not supported in iterators: 'myrec'"
file: "treciter.nim"
line: 9
"""