[Issue 15266] New: Parameters to methods of final classes become uninitialised in out contracts for DMD only
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Oct 30 07:32:08 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15266
Issue ID: 15266
Summary: Parameters to methods of final classes become
uninitialised in out contracts for 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 fails with DMD2.066 and 2.068; but succeeds with GDC2.066. I haven't
tested with LDC.
Making the class non-final fixes the problem. As does making property() a UFCS
function taking C as its first parameter.
--
More information about the Digitalmars-d-bugs
mailing list