Bug 15271 – Parameters of final classes become uninitialised in out contracts with DMD only
Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-31T13:02:00Z
Last change time
2015-10-31T14:14:45Z
Assigned to
nobody
Creator
lt.infiltrator
Comments
Comment #0 by lt.infiltrator — 2015-10-31T13:02:45Z
---------------------------------------------
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.
Comment #1 by lt.infiltrator — 2015-10-31T14:14:01Z
*** This issue has been marked as a duplicate of issue 15266 ***
Comment #2 by lt.infiltrator — 2015-10-31T14:14:45Z
I seem to have gone a little off the deep end and reported this again. My apologies.