Bug 1251 – Final template class w/ constructor and invariant causes compile error
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-05-31T01:52:00Z
Last change time
2015-06-09T01:14:38Z
Keywords
rejects-valid
Assigned to
nobody
Creator
dhaffey
Comments
Comment #0 by dhaffey — 2007-05-31T01:52:59Z
The following code:
final class Foo()
{
this() {}
invariant {}
}
alias Foo!() Bar;
Provokes this error message:
Error: cannot modify final variable '__result'
It compiles without issue if I remove the final attribute, the constructor, the invariant, make Foo a non-template class, or use the full template syntax instead of the class template shortcut.
I also hit this problem with v2.011 (with const).
.... __result cannot modify const
We should fix this.
Comment #3 by someanon — 2008-03-10T16:31:04Z
I hit this bug again, so I raise the priority.
I spent hours debugging a problem which should have been caught by an invariant vilation, but it's commentted out because of this bug.
Class invariant is a hallmark of DbC, we should fix this asap.
Comment #4 by yebblies — 2012-01-27T21:46:09Z
I can't get this to fail. It's most likely been fixed sometime in the last four years. Probably in the fixes for similar problems with out contracts.