www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1251] New: Final template class w/ constructor and invariant causes compile error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1251

           Summary: Final template class w/ constructor and invariant causes
                    compile error
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dhaffey gmail.com


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.


-- 
May 30 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1251





------- Comment #1 from thomas-dloop kuehne.cn  2007-08-25 16:41 -------
Added to DStress as
http://dstress.kuehne.cn/run/f/final_13_A.d
http://dstress.kuehne.cn/run/f/final_13_B.d
http://dstress.kuehne.cn/run/f/final_13_C.d
http://dstress.kuehne.cn/run/f/final_13_D.d


-- 
Aug 25 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1251





------- Comment #2 from someanon yahoo.com  2008-02-24 23:53 -------
I also hit this problem with v2.011 (with const).

.... __result cannot modify const

We should fix this.


-- 
Feb 24 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1251


someanon yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |someanon yahoo.com
           Severity|minor                       |normal
           Priority|P3                          |P2
            Version|1.014                       |2.012




------- Comment #3 from someanon yahoo.com  2008-03-10 16:31 -------
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.


-- 
Mar 10 2008