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
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 of skMacro, skTemplate: discard
else: else:
if callee.kind == skIterator and callee.id == c.p.owner.id: 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. # error correction, prevents endless for loop elimination in transf.
# See bug #2051: # See bug #2051:
result.sons[0] = newSymNode(errorSym(c, n)) 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" errThreadvarCannotInit = "a thread var cannot be initialized explicitly; this would only run for the main thread"
errImplOfXexpected = "implementation of '$1' expected" errImplOfXexpected = "implementation of '$1' expected"
errRecursiveDependencyX = "recursive dependency: '$1'" 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" 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 '()'?" errCannotAssignMacroSymbol = "cannot assign macro symbol to $1 here. Forgot to invoke the macro with '()'?"
errInvalidTypeDescAssign = "'typedesc' metatype is not valid here; typed '=' instead of ':'?" errInvalidTypeDescAssign = "'typedesc' metatype is not valid here; typed '=' instead of ':'?"

View file

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