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

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 3 yebblies 2011-08-03 07:37:22 UTC
*** Issue 6427 has been marked as a duplicate of this issue. ***