Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages for mismatched array literals #18902

Open
dlangBugzillaToGithub opened this issue Oct 25, 2014 · 0 comments
Open

Better error messages for mismatched array literals #18902

dlangBugzillaToGithub opened this issue Oct 25, 2014 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2014-10-25T14:38:40Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=13653

Description

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant