[Issue 4648] New: "In" contracts in interfaces missbehaving

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 15 12:59:17 PDT 2010


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

           Summary: "In" contracts in interfaces missbehaving
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2010-08-15 12:59:13 PDT ---
Code:

interface I
{
    int foo(int i)
      in { writeln(i); assert(i == 4); }
}

class Base : I
{
    int foo(int i)
    {
        return i;
    }
}

import std.stdio;

void main()
{
    auto b = new Base;
    b.foo(4);
}

The writeln will output garbage, ex: 
1630368629
core.exception.AssertError at test(83): Assertion failure

You can remove the writeln, but the assert still fails. I'm using the same
syntax as defined in the docs:
http://www.digitalmars.com/d/2.0/interface.html

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