dmd 1.057 and 2.041 release

bearophile bearophileHUGS at lycos.com
Fri Mar 12 09:04:00 PST 2010


> In 2.041 it has to be written like this:
> 
> real x = 1.2;
> 
> real[4][4] M2 = [
> 	[1, 0, 0, x],
> 	[0, 1, 0, x],
> 	[0, 0, 1, x],
> 	[0, 0, 0, cast(real)1]
> ];

I have seen something different, using dmd 2.041 on Windows. Here are few cases of code followed by the error messages dmd outputs to me.

A good way to write code that contains a little less bugs is to try all possible corner cases, systematically, orthogonally, trying all the little boxes you can find in the matrix/tensor of possibilities (like Guy Steele did when he designed Java attributes). I think dmd will need few more tons of tests.

-----------------------

real x = 1.2;
real[4][4] M2 = [[1, 0, 0, x],
                 [0, 1, 0, x],
                 [0, 0, 1, x],
                 [0, 0, 0, cast(real)1]];
void main() {}


test.d(5): Error: non-constant expression x
test.d(5): Error: non-constant expression x
test.d(5): Error: non-constant expression x

-----------------------

real x = 1.2;
real[4][4] M2 = [[1, 0, 0, x],
                 [0, 1, 0, x],
                 [0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}



bug1.d(5): Error: non-constant expression x
bug1.d(5): Error: non-constant expression x
bug1.d(5): Error: non-constant expression x

-----------------------

const real x = 1.2;
real[4][4] M2 = [[1, 0, 0, x],
                 [0, 1, 0, x],
                 [0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


No errors with const, immutable, enum.

-----------------------

const real x = 1.2;
real[4][4] M2 = [[0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


No errors.

-----------------------

const real x = 1.2;
real[4][2] M2 = [[0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


No errors.

-----------------------

const real x = 1.2;
real[2][4] M2 = [[0, 0, 1, x],
                 [0, 0, 0, 1]];
void main() {}


bug1.d(3): Error: cannot implicitly convert expression ([0,0,0,1]) of type int[] to real[2u]

This seems a wrong error message at best.

-----------------------

Can't x be mutable? So are array literals kinda constant now?
Do you see something that needs to go to Bugzilla?

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list