digitalmars.D.bugs - scope instantiation bug with alias template parameters
- Don Clugston (24/24) Nov 14 2005 In this example, outside() seems to be instantiated only once, with the
- Thomas Kuehne (12/36) Nov 19 2005 -----BEGIN PGP SIGNED MESSAGE-----
In this example, outside() seems to be instantiated only once, with the first use of test:local(). test.val is always 123, no matter what its template parameter is. (if you reverse the last two lines, then b passes and a fails -- test.val is always 456). I suspect this one is not trivial. --------------- template outside(alias s) { const int outval = s.localval; } template test(alias f) { template local() { const int localval = f.x; } const int val = outside!(local!()).outval; } template a() { const int x = 123; } template b() { const int x = 456; } static assert( test!( a!() ).val == 123); static assert( test!( b!() ).val == 456); int main() { return 0; } -----------
Nov 14 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Don Clugston schrieb am 2005-11-14:In this example, outside() seems to be instantiated only once, with the first use of test:local(). test.val is always 123, no matter what its template parameter is. (if you reverse the last two lines, then b passes and a fails -- test.val is always 456). I suspect this one is not trivial. --------------- template outside(alias s) { const int outval = s.localval; } template test(alias f) { template local() { const int localval = f.x; } const int val = outside!(local!()).outval; } template a() { const int x = 123; } template b() { const int x = 456; } static assert( test!( a!() ).val == 123); static assert( test!( b!() ).val == 456); int main() { return 0; } -----------Added to DStress as http://dstress.kuehne.cn/run/t/template_18_A.d http://dstress.kuehne.cn/run/t/template_18_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDf74O3w+/yD4P9tIRAvFKAKDJ/f+xUUrw39wgaUclKRnSq/GgHwCgyHTx NgrcT+TLiKnhJQ8Yzv8axjo= =twwc -----END PGP SIGNATURE-----
Nov 19 2005