Bug 10020 – Error: cannot modify struct this Slot with immutable members

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-03T02:32:00Z
Last change time
2013-05-03T05:15:12Z
Keywords
rejects-valid
Assigned to
nobody
Creator
jens.k.mueller

Comments

Comment #0 by jens.k.mueller — 2013-05-03T02:32:52Z
The following code produces the compiler error "Error: cannot modify struct this Slot with immutable members". I compiled using dmd v2.062 on Linux with "dmd file.d". I expected a proper diagnostics message on how to fix the problem or what's the root of the problem. Note, there are no line numbers. file test.d --- struct StructA { // commenting out postblit makes the error go away this(this) inout { } } struct StructB { // commenting out opEquals makes the error go away bool opEquals()(auto ref const StructB rhs) const { return true; } } struct StructC { StructA[int] _structA; // commenting out this makes the error go away StructB _structB; // commenting out this makes the error go away } void main(){} --- Besides improving the compiler diagnostics it is also helpful to understand the issue. I assume it's some const problem.
Comment #1 by maxim — 2013-05-03T04:34:13Z
Yes, this is known issue and was reported several times. Error message is correct and refers to AA druntime implementation opaque data structure which is hidden from user. Root case (plus variations with inout, opEquals, AA arrays, etc...): struct S { this(this){} } struct SS { const S s; } void main() { } I think diagnostic shouldn't be fixed here because it is a design problem.
Comment #2 by jens.k.mueller — 2013-05-03T04:43:13Z
(In reply to comment #1) > Yes, this is known issue and was reported several times. Error message is > correct and refers to AA druntime implementation opaque data structure which is > hidden from user. > > Root case (plus variations with inout, opEquals, AA arrays, etc...): > > struct S > { > this(this){} > } > > struct SS > { > const S s; > } > > void main() > { > } > > I think diagnostic shouldn't be fixed here because it is a design problem. Many thanks for the prompt reply. Can you make this report a duplicate then? I haven't found related issues. The problem is then the AA implementation, right? Any schedule on when it will be fixed?
Comment #3 by maxim — 2013-05-03T05:15:12Z
Marked as duplicate. After lurking through bugzilla search I found many issues close to this one, but 8954 seems the most relevant. *** This issue has been marked as a duplicate of issue 8954 ***