6512 – [CTFE] new T[][] doesn't work

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6512 - [CTFE] new T[][] doesn't work
Summary: [CTFE] new T[][] doesn't work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2011年08月16日 13:51 UTC by bearophile_hugs
Modified: 2011年08月24日 12:58 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011年08月16日 13:51:20 UTC
This is almost an enhancement request.
int foo() {
 new int[][](1, 1);
 return 0;
}
enum _ = foo();
void main() {}
test.d(2): Error: Cannot interpret new int[][](1u,1u) at compile time
test.d(5): Error: cannot evaluate foo() at compile time
While this code works:
int foo() {
 int[][] m;
 m.length = 1;
 m[0].length = 1;
 assert(m == [[0]]);
 return 0;
}
enum _ = foo();
void main() {}


AltStyle によって変換されたページ (->オリジナル) /