D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13653 - Better error messages for mismatched array literals
Summary: Better error messages for mismatched array literals
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-25 14:38 UTC by bearophile_hugs
Modified: 2024-12-13 18:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2014-10-25 14:38:40 UTC
void main() {
    uint[1][2] arr1 = [[0, 0]];
    int[2] arr2 = [1.5, 2.5];
}


DMD 2.067alpha gives a strange error messages:

test.d(2,23): Error: cannot implicitly convert expression ([[0, 0]]) of type int[][] to uint[]
test.d(3,19): Error: cannot implicitly convert expression ([1.5, 2.5]) of type double[] to int[]


But I suggest to give more clear error message, something like:

test.d(2,23): Error: array sizes mismatch, cannot implicitly convert array literal of shape (2, 1) to shape (1, 2)
test.d(3,19): Error: cannot implicitly convert expression ([1.5, 2.5]) of type double[] to int[2]
Comment 1 dlangBugzillaToGithub 2024-12-13 18:32:14 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

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

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