[Issue 15271] New: Parameters of final classes become uninitialised in out contracts with DMD only
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Sat Oct 31 06:02:45 PDT 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15271
          Issue ID: 15271
           Summary: Parameters of final classes become uninitialised in
                    out contracts with DMD only
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: lt.infiltrator at gmail.com
---------------------------------------------
final class C {
   void property(uint rate)
   out {
      assert(_rate == rate, "This will fail");
   } body { _rate = rate; }
   this() { }
   uint _rate;
}
void main() {
   auto c = new C;
   c.property = 25;
}
---------------------------------------------
This only fails with DMD. v2.068 for sure; and as far back as 2.065 if memory
serves.  I'm not sure whether it ever worked with DMD.  It works fine with GDC.
 I haven't tested it with LDC.
If the class is made non-final, or the method is made a UFCS function taking C
as the first parameter, then the issue disappears.
Rationale for the "critical" severity: first-class support for unittests and
contracts is one of the big selling points for D.  Therefore, out contracts not
working properly seems like a critical issue.  Feel free to disagree.
--
    
    
More information about the Digitalmars-d-bugs
mailing list