3722 – A method without an in contract should always succeed, even if overridden

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3722 - A method without an in contract should always succeed, even if overridden
Summary: A method without an in contract should always succeed, even if overridden
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
Reported: 2010年01月19日 01:25 UTC by Kazuhiro Inaba
Modified: 2015年06月09日 01:27 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Kazuhiro Inaba 2010年01月19日 01:25:04 UTC
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.
Comment 1 yebblies 2011年07月02日 11:43:03 UTC
https://github.com/D-Programming-Language/dmd/pull/192 


AltStyle によって変換されたページ (->オリジナル) /