D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11105 - Error on struct with multidimentional static array initialization from its element
Summary: Error on struct with multidimentional static array initialization from its el...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2013-09-22 23:12 UTC by Denis Shelomovskii
Modified: 2013-10-03 13:58 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Denis Shelomovskii 2013-09-22 23:12:17 UTC
This used to compile:
---
struct S
{ int[2][1] a21; }

void main()
{
    S s = S([1, 2]); // Error: cannot implicitly convert expression ([1, 2]) of type int[] to int[2u][1u]
}
---

Not sure about validity of the issue as documentation doesn't provide exact implicit conversions on struct initialization.
Comment 1 Don 2013-09-23 03:38:45 UTC
> Not sure about validity of the issue as documentation doesn't provide exact
implicit conversions on struct initialization.

I'm not sure either.

struct S
{
    int [2][1] xx = [1, 2];
}

prints:
test.d(3): Error: array initializer has 2 elements, but array length is 1.

So the struct literal behaviour is consistent with that. Yet,

void main()
{
    int [2][1] xx = [1, 2];
}

is accepted. I think the difference in behaviour is hard to justify.
Comment 3 github-bugzilla 2013-10-03 13:58:14 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d4638f1f70c602987f1e0cab62818d399b64a219
fix Issue 11105 - Error on struct with multidimentional static array initialization from its element

https://github.com/D-Programming-Language/dmd/commit/efcd62c6d5c1ac1b59cba6c5eb546803c2c5931f
Merge pull request #2611 from 9rnsr/fix11105

[REG2.064a] Issue 11105 - Error on struct with multidimentional static array initialization from its element