mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 14:23:45 +00:00
closes #6013, closes #7009, closes #9190, closes #12487, closes #12831, closes #13184, closes #13252, closes #14860, closes #14877, closes #14894, closes #14917, closes #16153, closes #16439, closes #17779, closes #18074, closes #18202, closes #18314, closes #18648, closes #19063, closes #19446, closes #20065, closes #20367, closes #22126, closes #22820, closes #22888, closes #23020, closes #23287, closes #23510
51 lines
720 B
Nim
51 lines
720 B
Nim
discard """
|
|
output: '''
|
|
1
|
|
2
|
|
3
|
|
FooBar
|
|
foo1
|
|
foo2
|
|
foo3
|
|
seq[int]
|
|
@[5, 6]
|
|
'''
|
|
"""
|
|
|
|
# issue #13252
|
|
|
|
import macros
|
|
|
|
type
|
|
FooBar = object
|
|
a: seq[int]
|
|
|
|
macro genFoobar(fb: static FooBar): untyped =
|
|
result = newStmtList()
|
|
for b in fb.a:
|
|
result.add(newCall(bindSym"echo", newLit b))
|
|
|
|
proc foobar(fb: static FooBar) =
|
|
genFoobar(fb)
|
|
echo fb.type # added line, same error when wrapped in static:
|
|
# Error: undeclared field: 'a'
|
|
for b in fb.a:
|
|
echo "foo" & $b
|
|
|
|
proc main() =
|
|
const a: seq[int] = @[1, 2, 3]
|
|
const fb = Foobar(a: a)
|
|
foobar(fb)
|
|
main()
|
|
|
|
# issue #14917
|
|
|
|
proc passSeq2[T](a : static seq[T]) =
|
|
echo a
|
|
|
|
template passSeq1[T](a : static seq[T]) =
|
|
echo type(a)
|
|
passSeq2(a)
|
|
|
|
passSeq1(@[5,6])
|