D - [bug] array initializer
- Lars Ivar Igesund (10/10) Apr 16 2004 The docs say that this works:
- J Anderson (9/20) Apr 16 2004 This works, outside the main scope and the error message explains that.
-
Stewart Gordon
(10/14)
Apr 16 2004
- Vathix (6/19) Apr 16 2004 I think it just hasn't been implemented yet. The workaround is:
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
This works, outside the main scope and the error message explains that.
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 ];<snip>array.d(3): variable def is not a static and cannot have static initializer<snip> Yes, there seem to be some arbitrary restrictions that aren't in the spec. See http://www.digitalmars.com/drn-bin/wwwnews?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> 