fixes #21476; internal error: proc has no result symbol (#25192)

fixes #21476
This commit is contained in:
ringabout
2025-09-25 00:40:32 +08:00
committed by GitHub
parent ceaa7fb4e8
commit 3e2852cb1b
2 changed files with 17 additions and 0 deletions

View File

@@ -2644,9 +2644,18 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
else:
nil
# semantic checking also needed with importc in case used in VM
let isInlineIterator = isInlineIterator(s.typ)
s.ast[bodyPos] = hloBody(c, semProcBody(c, n[bodyPos], resultType))
# unfortunately we cannot skip this step when in 'system.compiles'
# context as it may even be evaluated in 'system.compiles':
if isInlineIterator and s.typ.callConv == ccClosure:
# iterators without explicit callconvs are lifted to closure,
# we need to add a result symbol for them
maybeAddResult(c, s, n)
trackProc(c, s, s.ast[bodyPos])
else:
if (s.typ.returnType != nil and s.kind != skIterator):

View File

@@ -5,3 +5,11 @@ proc f() =
iterator b(): int =
for x in a(): yield x
proc y(n: ref int) = discard
proc w(n: ref int) =
iterator a(): int = y(n)
let x = a
w(nil)