www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15984] New: Interface contracts retrieve garbage instead of

https://issues.dlang.org/show_bug.cgi?id=15984

          Issue ID: 15984
           Summary: Interface contracts retrieve garbage instead of
                    parameters
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: contracts, wrong-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: verylonglogin.reg gmail.com
            Blocks: 7517

This code should run fine:
---
interface I
{
    void f(int i)
    in { assert(i == 5); } // Fails
}

class C : I
{
    void f(int i)
    in { } // To call contract
    body { }
}

void main()
{
    I i = new C;
    i.f(5);
}
---

Note: `(new C).f(5)` fails too but let's support correct contract
implementation (i.e. contract is called based on static type) in testcase.

--
May 02 2016