Skip to content

Commit 3e2852c

Browse files
authored
fixes #21476; internal error: proc has no result symbol (#25192)
fixes #21476
1 parent ceaa7fb commit 3e2852c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compiler/semstmts.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,9 +2644,18 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
26442644
else:
26452645
nil
26462646
# semantic checking also needed with importc in case used in VM
2647+
2648+
let isInlineIterator = isInlineIterator(s.typ)
26472649
s.ast[bodyPos] = hloBody(c, semProcBody(c, n[bodyPos], resultType))
26482650
# unfortunately we cannot skip this step when in 'system.compiles'
26492651
# context as it may even be evaluated in 'system.compiles':
2652+
2653+
if isInlineIterator and s.typ.callConv == ccClosure:
2654+
# iterators without explicit callconvs are lifted to closure,
2655+
# we need to add a result symbol for them
2656+
maybeAddResult(c, s, n)
2657+
2658+
26502659
trackProc(c, s, s.ast[bodyPos])
26512660
else:
26522661
if (s.typ.returnType != nil and s.kind != skIterator):

tests/iter/titer14.nim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ proc f() =
55

66
iterator b(): int =
77
for x in a(): yield x
8+
9+
proc y(n: ref int) = discard
10+
11+
proc w(n: ref int) =
12+
iterator a(): int = y(n)
13+
let x = a
14+
15+
w(nil)

0 commit comments

Comments
 (0)