Thread overview
[Issue 15359] DMD incorrectly identifies type of multidimensional array
Nov 18, 2015
Jack Stouffer
Nov 18, 2015
Alex Parrill
Nov 18, 2015
Jack Stouffer
Dec 17, 2022
Iain Buclaw
November 18, 2015
https://issues.dlang.org/show_bug.cgi?id=15359

tanel58@hotmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tanel58@hotmail.com

--- Comment #1 from tanel58@hotmail.com ---
I believe you mean "int[2][5] data = ...".

--
November 18, 2015
https://issues.dlang.org/show_bug.cgi?id=15359

--- Comment #2 from Jack Stouffer <jack@jackstouffer.com> ---
(In reply to Tanel Tagaväli from comment #1)
> I believe you mean "int[2][5] data = ...".

Yes I did. I improperly reduced a bug I ran into.

Here is a better illustration of the problem

------
void main() {
    int[][] data = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]];
    int[2][5] d = data;
}
------

Maybe it's just a question of a bad error message, because if taking the data from a dynamic array and saving it into a static array is not allowed it should say something like

------
Error: cannot implicitly convert expression (data) of type int[][] to int[2][5]
------

But instead it says

------
Error: cannot implicitly convert expression (data) of type int[][] to int[]
------

--
November 18, 2015
https://issues.dlang.org/show_bug.cgi?id=15359

Alex Parrill <initrd.gz@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |initrd.gz@gmail.com

--- Comment #3 from Alex Parrill <initrd.gz@gmail.com> ---
(In reply to Jack Stouffer from comment #2)
> (In reply to Tanel Tagaväli from comment #1)
> > I believe you mean "int[2][5] data = ...".
> 
> Yes I did. I improperly reduced a bug I ran into.
> 
> Here is a better illustration of the problem
> 
> ------
> void main() {
>     int[][] data = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]];
>     int[2][5] d = data;
> }
> ------
> 
> Maybe it's just a question of a bad error message, because if taking the data from a dynamic array and saving it into a static array is not allowed it should say something like
> 
> ------
> Error: cannot implicitly convert expression (data) of type int[][] to
> int[2][5]
> ------
> 
> But instead it says
> 
> ------
> Error: cannot implicitly convert expression (data) of type int[][] to int[]
> ------

Fixed-sized arrays (like `int[2][5]`) have different semantics than slices
(like `int[][]`); you'll have to assign the elements manually.

--
November 18, 2015
https://issues.dlang.org/show_bug.cgi?id=15359

--- Comment #4 from Jack Stouffer <jack@jackstouffer.com> ---
(In reply to Alex Parrill from comment #3)
> Fixed-sized arrays (like `int[2][5]`) have different semantics than slices
> (like `int[][]`); you'll have to assign the elements manually.

Ok, so it's a poor error message that should be fixed.

--
February 15, 2016
https://issues.dlang.org/show_bug.cgi?id=15359

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |hsteoh@quickfur.ath.cx

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15359

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=15359

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19072

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--