[Issue 4562] New: D2 Language Docs: http://www.digitalmars.com/d/2.0/dbc.html

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 1 14:58:16 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4562

           Summary: D2 Language Docs:
                    http://www.digitalmars.com/d/2.0/dbc.html
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2010-08-01 14:58:13 PDT ---
It states:

"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."

But my example proves otherwise:

class A
{
    int test(int x)
    {
        return x * 2;
    }
}

class B : A
{
    int test(int x)
    in
    {
        assert(x == 20);
    }
    body
    {
        return x * 2;
    }
}

void main() {
    B b = new B;
    b.test(10);
}

This will raise an assert error, which would negate the statement "in contracts
on functions overriding it have no useful effect.".

-- 
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