mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
fixes #21476
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user