digitalmars.D.bugs - Properties as template value parameters
- Don Clugston <dac nospam.com.au> Nov 28 2005
- "John C" <johnch_atms hotmail.com> Nov 28 2005
- Don Clugston <dac nospam.com.au> Nov 28 2005
- Thomas Kuehne <thomas-dloop kuehne.cn> Dec 04 2005
Seems to be an order-of-evaluation bug.
Fails to compile on DMD 0.140, Windows.
--------------
template cat(int n)
{
const int dog = n;
}
const char [] bird = "canary";
const int sheep = cat!(bird.length).dog;
int main() { return 0; }
--------------
bug.d(9): no property 'length' for type 'char[]'
----------------
Nov 28 2005
"Don Clugston" <dac nospam.com.au> wrote in message news:dmef15$1nll$1 digitaldaemon.com...Seems to be an order-of-evaluation bug. Fails to compile on DMD 0.140, Windows. -------------- template cat(int n) { const int dog = n; } const char [] bird = "canary"; const int sheep = cat!(bird.length).dog;
Works if you cast bird to char[]: const int sheep = cat!((cast(char[])bird).length).dog; printf("%d\n", sheep); // prints '6'int main() { return 0; } -------------- bug.d(9): no property 'length' for type 'char[]' ----------------
Nov 28 2005
John C wrote:"Don Clugston" <dac nospam.com.au> wrote in message news:dmef15$1nll$1 digitaldaemon.com...Seems to be an order-of-evaluation bug. Fails to compile on DMD 0.140, Windows. -------------- template cat(int n) { const int dog = n; } const char [] bird = "canary"; const int sheep = cat!(bird.length).dog;
Works if you cast bird to char[]: const int sheep = cat!((cast(char[])bird).length).dog; printf("%d\n", sheep); // prints '6'
Indeed, many minor changes will let it compile, eg const int sheep = cat!((""~ bird).length).dog; and const int pig = bird.length; const int sheep = cat!(pig).dog; (I got sick of a,b,c in bug reports, from now on I'll use animals :-) Of course insects would be more appropriate).int main() { return 0; } -------------- bug.d(9): no property 'length' for type 'char[]' ----------------
Nov 28 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Don Clugston schrieb am 2005-11-28:Seems to be an order-of-evaluation bug. Fails to compile on DMD 0.140, Windows. -------------- template cat(int n) { const int dog = n; } const char [] bird = "canary"; const int sheep = cat!(bird.length).dog; int main() { return 0; } -------------- bug.d(9): no property 'length' for type 'char[]' ----------------
Added to DStress as http://dstress.kuehne.cn/run/t/template_22.d http://dstress.kuehne.cn/run/t/template_class_15.d http://dstress.kuehne.cn/run/t/template_struct_06.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDk0x83w+/yD4P9tIRAiyeAKDLPIVbZEeUEerdcj1f6yW49yDFxwCeIM2o ajFvNDtVF3EUC0oapTQfZFw= =29a+ -----END PGP SIGNATURE-----
Dec 04 2005









Don Clugston <dac nospam.com.au> 