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

Whole-array initialization for static fixed-size arrays of arrays too #18919

Open
dlangBugzillaToGithub opened this issue Nov 30, 2014 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2014-11-30T11:13:21Z

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

Description

Please allow the missing common case too:


int[2][2] m1 = [[1, 1], [1, 1]]; // OK
int[2][2] m2 = 1; // Error
void main() {
    int[2][2] m3 = [[1, 1], [1, 1]]; // OK
    int[2][2] m4 = 1; // OK
}


dmd 2.067alpha:

test.d(2,16): Error: cannot implicitly convert expression (1) of type int to int[2][2]


It's expecially useful when the size is a compile-time constant defined elsewhere that is not known locally:

enum N = 5;
int[N][N] m = 1; // Error
void main() {}
@dlangBugzillaToGithub
Copy link
Author

k.hara.pg commented on 2014-12-01T02:04:58Z

I think the multi-dimensional block initializing for static array type should consistently work in arbitrary scope.

To increase behavior consistency of variable initializing, my following PR will fix it.

https://github.com/D-Programming-Language/dmd/pull/3680

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