Bug 3722 – A method without an in contract should always succeed, even if overridden
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-01-19T01:25:00Z
Last change time
2015-06-09T01:27:23Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
kiki
Comments
Comment #0 by kiki — 2010-01-19T01:25:04Z
In dmd 2.039, the following code fails to pass the in-contract.
class Base
{
void method() {}
}
class Derived : Base
{
void method() in { assert(false); } body {}
}
void main()
{
Base b = new Derived;
b.method();
}
But, according to the spec, IIUC, it should successfully pass the check.
> A function without an in contract means that any values of the function parameters are allowed. This implies that if any function in an inheritance hierarchy has no in contract, then in contracts on functions overriding it have no useful effect.
If I add an explicit empty in-contract to Base.method:
void method() in{} body{}
then it passes the check.