6355 – Template constructor cannot initialize non-mutable field

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6355 - Template constructor cannot initialize non-mutable field
Summary: Template constructor cannot initialize non-mutable field
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
: 6427 (view as issue list)
Depends on:
Blocks:
Reported: 2011年07月20日 02:17 UTC by Kenji Hara
Modified: 2011年08月03日 07:37 UTC (History)
2 users (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 Kenji Hara 2011年07月20日 02:17:09 UTC
This is valid D2 code, but couldn't compile.
----
struct S
{
 const int value;
 this()(int n){ value = n; }
}
void main()
{
 S s = S(10);
}
----
test.d(4): Error: can only initialize const member value inside constructor
test.d(8): Error: template instance test.S.__ctor!() error instantiating
----
Comment 1 Kenji Hara 2011年07月20日 03:04:48 UTC
https://github.com/D-Programming-Language/dmd/pull/266 
Comment 3 yebblies 2011年08月03日 07:37:22 UTC
*** Issue 6427 has been marked as a duplicate of this issue. ***


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