www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - some strange behavior

reply \/\/o <spam protection.now> writes:
Writing a small opengl text printer (vertex based) I have found that the next
lines are "illegal" to dmd (2.031):

invariant float[][][] CHARS =[
    [//A
	[0,0],
	[1/2f,2],
	[1,0],
	[3/4f,1],
	[1/4f,1]
    ]
];

dmd complains (compiling with dmd -c bug.d):
bug.d(9): Error: cannot implicitly convert expression ([0.5F,2F]) of type
float[2u] to int[]    
bug.d(9): Error: cannot implicitly convert expression ([0.75F,1F]) of type
float[2u] to int[]   
bug.d(9): Error: cannot implicitly convert expression ([0.25F,1F]) of type
float[2u] to int[]  

is this a bug?

thanks.
------
if this mesage is repeated there's a problem with my browser
Aug 08 2009
parent Frank Benoit <keinfarbton googlemail.com> writes:
//o schrieb:
 Writing a small opengl text printer (vertex based) I have found that the next
lines are "illegal" to dmd (2.031):
 
 invariant float[][][] CHARS =[
     [//A
 	[0,0],
 	[1/2f,2],
 	[1,0],
 	[3/4f,1],
 	[1/4f,1]
     ]
 ];
 
 dmd complains (compiling with dmd -c bug.d):
 bug.d(9): Error: cannot implicitly convert expression ([0.5F,2F]) of type
float[2u] to int[]    
 bug.d(9): Error: cannot implicitly convert expression ([0.75F,1F]) of type
float[2u] to int[]   
 bug.d(9): Error: cannot implicitly convert expression ([0.25F,1F]) of type
float[2u] to int[]  
 
 is this a bug?
 
 thanks.
 ------
 if this mesage is repeated there's a problem with my browser
The type of the first element makes the type of the array literal. "0" is of type int, try 0f. invariant float[][][] CHARS =[ [//A [0f,0], [1/2f,2], [1,0], [3/4f,1], [1/4f,1] ] ];
Aug 09 2009