const AB c = {a,20, numbers};
Kenji Hara
k.hara.pg at gmail.com
Mon Apr 16 18:08:37 PDT 2012
On Monday, 16 April 2012 at 14:50:43 UTC, sclytrack wrote:
>
> struct AB
> {
> int a;
> int b;
> int [] numbers;
> }
>
> int main()
> {
> int a = 300;
> const int [] numbers = new int[2];
> const AB c = {a,20, numbers}; // line 66
> writeln(c);
> return 0;
> }
>
> ----------------------------
> -debug
> -unittest
>
> src/main.d(66): Error: cannot implicitly convert expression
> (numbers) of type const(int[]) to int[]
>
> ---------------------------
>
>
> const AB c;
>
> typeof(c.a) is const(int);
> typeof(c.numbers) is const(int []);
>
>
> Shouldn't the code above accept the const(int []) ?
Should do. It is a compiler bug.
I've filed this issue in bugzilla:
http://d.puremagic.com/issues/show_bug.cgi?id=7929
And posted a pull request to fix compiler code:
https://github.com/D-Programming-Language/dmd/pull/884
Thanks.
Kenji Hara
More information about the Digitalmars-d-learn
mailing list