diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-05-09 11:53:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-09 11:53:29 +0200 |
commit | 532edc3e9a9e5bd4ad8780aad304cef6932213ed (patch) | |
tree | ef223003f698150311c383ca2d33a53c034d126e | |
parent | 541751305c4094b8e88200ec2e3f37bed652925b (diff) | |
parent | 55a3b51e40a7d3301a114a66712c5daebae0ac6d (diff) | |
download | Nim-532edc3e9a9e5bd4ad8780aad304cef6932213ed.tar.gz |
Merge pull request #11208 from JasperJenkins/10139
Fix typdesc arg iterators
-rw-r--r-- | compiler/transf.nim | 1 | ||||
-rw-r--r-- | tests/iter/titertypedesc.nim | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim index 0e788b833..c4da48d53 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -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 diff --git a/tests/iter/titertypedesc.nim b/tests/iter/titertypedesc.nim new file mode 100644 index 000000000..a69f703c6 --- /dev/null +++ b/tests/iter/titertypedesc.nim @@ -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 |