Summary: Precondition contract checks should be statically
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2011-10-26 14:08:40 PDT ---
import std.stdio;

class A{
    void foo()in{writeln("A, in!");assert(false);}out{writeln("A,
class B:A{
    override void foo()in{writeln("B, in!");}out{writeln("B, out!");}body{}

void main(){
    A x = new B;; // 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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to