[Issue 6857] New: Precondition contract checks should be statically bound.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 26 14:09:47 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6857
Summary: Precondition contract checks should be statically
bound.
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: timon.gehr at gmx.ch
--- Comment #0 from timon.gehr at gmx.ch 2011-10-26 14:08:40 PDT ---
import std.stdio;
class A{
void foo()in{writeln("A, in!");assert(false);}out{writeln("A,
out!");}body{}
}
class B:A{
override void foo()in{writeln("B, in!");}out{writeln("B, out!");}body{}
}
void main(){
A x = new B;
x.foo(); // prints all four messages
}
It is an error for the caller of foo to rely on the widened interface of B,
because the static type of x is A. Therefore only the in-contract of A should
be checked. The way it is now, in contracts provide no means of reasoning about
the validity of the code if the dynamic type of some instance is unknown during
compilation.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list