D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23137 - Matrix init rejected in module scope but accepted at function scope
Summary: Matrix init rejected in module scope but accepted at function scope
Status: RESOLVED DUPLICATE of issue 19178
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2022-05-25 08:32 UTC by rm
Modified: 2022-06-21 15:44 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 rm 2022-05-25 08:32:08 UTC
The following code does no compile with the error:
onlineapp.d(3): Error: cannot implicitly convert expression `0` of type `int` to `int[6][3]`

But for the simpler case of vector and if the matrix is in a function scope it works, just like the specification states https://dlang.org/spec/arrays.html#rectangular-arrays

```d
import std;

int[6][3] matrix = 0;
int[6] vector = 0;
void main()
{
    int[6][3] stackMatrix = 0;
}
```
Comment 1 Dennis 2022-06-21 15:44:45 UTC

*** This issue has been marked as a duplicate of issue 19178 ***