[Issue 10562] New: Cannot initialize arrays by an element value when the elements are fixed-length arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 6 22:05:23 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10562
Summary: Cannot initialize arrays by an element value when the
elements are fixed-length arrays
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: acehreli at yahoo.com
--- Comment #0 from Ali Cehreli <acehreli at yahoo.com> 2013-07-06 22:05:22 PDT ---
We know that arrays can be initialized by a single element value:
void main()
{
int value = 1;
int[2] a = value;
assert(a == [ 1, 1 ]);
}
The bug is that it does not work when the elements are fixed-length arrays
themselves:
void main()
{
int[3] value = [ 1, 2, 3 ];
int[3][2] a = value; // <-- COMPILATION ERROR
assert(a == [ [ 1, 2, 3 ], [ 1, 2, 3 ] ]);
}
Error: mismatched array lengths, 6 and 3
On the other hand, the array can be initialized by an element-of-an-element:
void main()
{
// Note: This is the type of an element of array elements
int value = 1;
int[3][2] a = value;
assert(a == [ [ 1, 1, 1 ], [ 1, 1, 1 ] ]);
}
Is that a feature or perhaps a consequence of the reported bug?
Ali
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list