Bug 586 – Cannot index tuple with non-type elements

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-11-23T05:38:00Z
Last change time
2014-02-15T13:21:00Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
kirklin.mcdonald

Comments

Comment #0 by kirklin.mcdonald — 2006-11-23T05:38:28Z
Take the following code: template Tu(T ...) { alias T[1] Tu; // Line 2 } void foo() { } void main() { alias Tu!(real, int) T; // Works, no problem. alias Tu!(4, int) U; // Results in error. alias Tu!(foo, int) V; // Results in error. alias Tu!("a", int) W; // Results in error. } The error in all three cases is: test.d(2): tuple T is used as a type test.d(X): template instance test.Tu!(<whatever>, int) error instantiating Any tuple containing elements which are not types cannot be indexed. This limits certain kinds of advanced template code. Bug 533 is a consequence of this bug. Bug 582 is essentially the same bug, but refers to slicing tuples rather than indexing them.
Comment #1 by thomas-dloop — 2006-11-25T12:05:40Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-11-23: > http://d.puremagic.com/issues/show_bug.cgi?id=586 > Take the following code: > > template Tu(T ...) { > alias T[1] Tu; // Line 2 > } > > void foo() { } > > void main() { > alias Tu!(real, int) T; // Works, no problem. > alias Tu!(4, int) U; // Results in error. > alias Tu!(foo, int) V; // Results in error. > alias Tu!("a", int) W; // Results in error. > } > > The error in all three cases is: > > test.d(2): tuple T is used as a type > test.d(X): template instance test.Tu!(<whatever>, int) error instantiating > > Any tuple containing elements which are not types cannot be indexed. This > limits certain kinds of advanced template code. > > Bug 533 is a consequence of this bug. Bug 582 is essentially the same bug, but > refers to slicing tuples rather than indexing them. Added to DStress as http://dstress.kuehne.cn/compile/t/tuple_04_A.d http://dstress.kuehne.cn/compile/t/tuple_04_B.d http://dstress.kuehne.cn/compile/t/tuple_04_C.d http://dstress.kuehne.cn/compile/t/tuple_04_D.d http://dstress.kuehne.cn/compile/t/tuple_04_E.d http://dstress.kuehne.cn/compile/t/tuple_04_F.d http://dstress.kuehne.cn/compile/t/tuple_04_G.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFaI9YLK5blCcjpWoRAh5gAJoCHpGLGO1LRaQL9+xe0x4YhOgYxgCfVpYg CkX8VYBKc4X7fOVmS6zcHkw= =NTfb -----END PGP SIGNATURE-----
Comment #2 by reiner.pope — 2007-04-08T19:20:37Z
This is even true for the perhaps simpler version, with a pure expression tuple: int F; template A(T...) { alias T[0] B; // Fails here } alias A!(F) C; aliases.d(5): tuple T is used as a type aliases.d(8): template instance aliases.A!(F) error instantiating
Comment #3 by thomas-dloop — 2007-04-27T12:38:51Z
Fixed DMD 1.013
Comment #4 by bugzilla — 2008-06-30T01:39:29Z
Works in dmd 2.015 too.