[Issue 15359] DMD incorrectly identifies type of multidimensional array

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Nov 18 14:07:59 PST 2015


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

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

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

--- Comment #3 from Alex Parrill <initrd.gz at 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.

--


More information about the Digitalmars-d-bugs mailing list