D - [bug] array initializer
- Lars Ivar Igesund <larsivar igesund.net> Apr 16 2004
- J Anderson <REMOVEanderson badmama.com.au> Apr 16 2004
- Stewart Gordon <smjg_1998 yahoo.com> Apr 16 2004
- Vathix <vathix dprogramming.com> Apr 16 2004
The docs say that this works:
int [] def = [ 1, 2, 3 ];
This program fails to compile with the error message below:
void main()
{
int [] def = [ 1, 2, 3 ];
}
array.d(3): variable def is not a static and cannot have static initializer
Either the docs are wrong, or it's a compiler bug.
Lars Ivar Igesund
Apr 16 2004
Lars Ivar Igesund wrote:The docs say that this works: int [] def = [ 1, 2, 3 ]; This program fails to compile with the error message below: void main() { int [] def = [ 1, 2, 3 ]; } array.d(3): variable def is not a static and cannot have static initializer Either the docs are wrong, or it's a compiler bug. Lars Ivar Igesund
int [] def = [ 1, 2, 3 ]; void main() { } It would be nice if what u suggest worked though. -- -Anderson: http://badmama.com.au/~anderson/
Apr 16 2004
Lars Ivar Igesund wrote:The docs say that this works: int [] def = [ 1, 2, 3 ];
array.d(3): variable def is not a static and cannot have static initializer
Yes, there seem to be some arbitrary restrictions that aren't in the spec. See D/26695 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on on the 'group where everyone may benefit.
Apr 16 2004
Lars Ivar Igesund wrote:The docs say that this works: int [] def = [ 1, 2, 3 ]; This program fails to compile with the error message below: void main() { int [] def = [ 1, 2, 3 ]; } array.d(3): variable def is not a static and cannot have static initializer
I think it just hasn't been implemented yet. The workaround is: const int[] def_init = [1, 2, 3]; int[] def = def_init; -- Christopher E. Miller
Apr 16 2004









J Anderson <REMOVEanderson badmama.com.au> 