mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
fix complex typdesc iterators
This commit is contained in:
@@ -560,6 +560,7 @@ type
|
||||
proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
|
||||
# This analyses how to treat the mapping "formal <-> arg" in an
|
||||
# inline context.
|
||||
if formal.kind == tyTypeDesc: return paDirectMapping
|
||||
if skipTypes(formal, abstractInst).kind in {tyOpenArray, tyVarargs}:
|
||||
if arg.kind == nkStmtListExpr:
|
||||
return paComplexOpenarray
|
||||
|
||||
17
tests/iter/titertypedesc.nim
Normal file
17
tests/iter/titertypedesc.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
discard """
|
||||
output: '''0
|
||||
(id: 0)
|
||||
@[]
|
||||
[0, 0, 0]'''
|
||||
"""
|
||||
|
||||
iterator foo*(T: typedesc): T =
|
||||
var x: T
|
||||
yield x
|
||||
|
||||
for a in foo(int): echo a
|
||||
for b in foo(tuple[id: int]): echo b
|
||||
for c in foo(seq[int]): echo c
|
||||
|
||||
type Generic[T] = T
|
||||
for d in foo(Generic[array[0..2, int]]): echo d
|
||||
Reference in New Issue
Block a user