[Issue 13653] New: Better error messages for mismatched array literals
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Oct 25 07:38:40 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13653
Issue ID: 13653
Summary: Better error messages for mismatched array literals
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
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]
--
More information about the Digitalmars-d-bugs
mailing list