mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-29 18:53:58 +00:00
fix wrong error for iterators with no body and pragma macro (#24440)
fixes #16413 `semIterator` checks if the original iterator passed to it has no body, but it should check the processed node created by `semProcAux`.
This commit is contained in:
17
tests/pragmas/titeratormacro.nim
Normal file
17
tests/pragmas/titeratormacro.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
# issue #16413
|
||||
|
||||
import std/macros
|
||||
|
||||
macro identity(x: untyped) =
|
||||
result = x.copy()
|
||||
result[6] = quote do:
|
||||
yield 1
|
||||
discard result.toStrLit
|
||||
|
||||
iterator demo(): int {.identity.}
|
||||
iterator demo2(): int {.identity.} = discard # but this works as expected
|
||||
|
||||
var s: seq[int] = @[]
|
||||
for e in demo():
|
||||
s.add(e)
|
||||
doAssert s == @[1]
|
||||
Reference in New Issue
Block a user