5840 – Cannot assign to an array member of struct in CTFE

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5840 - Cannot assign to an array member of struct in CTFE
Summary: Cannot assign to an array member of struct in CTFE
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2011年04月13日 01:31 UTC by kennytm
Modified: 2011年04月30日 11:30 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 kennytm 2011年04月13日 01:31:50 UTC
(This is a bug regarding the trunk version of DMD (commit ea65289). The following code works fine in 2.052.)
In the latest version of DMD on github, assigning to an array member of a struct in compile-time is rejected.
-----------------
struct Foo {
 string g;
}
Foo f() {
 Foo x;
 x.g = "y"; // Error: x.g = "y" cannot be evaluated at compile time
 return x;
}
pragma(msg, f());
-----------------
This causes tuple of string cannot be created in compile-time. The struct literal `Foo("y")` works though.
Comment 1 kennytm 2011年04月26日 07:22:07 UTC
The bug was introduced in commit d96bbcb3cbf7cd561c47.
(https://github.com/D-Programming-Language/dmd/commit/d96bbcb3cbf7cd561c477497c872d616ae5343a1)


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