Thread overview
[Issue 3722] New: A method without an in contract should always succeed, even if overridden
Jan 19, 2010
Kazuhiro Inaba
Jul 02, 2011
yebblies
Jul 03, 2011
Walter Bright
January 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3722

           Summary: A method without an in contract should always succeed,
                    even if overridden
           Product: D
           Version: 2.039
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: kiki@kmonos.net


--- Comment #0 from Kazuhiro Inaba <kiki@kmonos.net> 2010-01-19 01:25:04 PST ---
In dmd 2.039, the following code fails to pass the in-contract.

class Base
{
   void method() {}
}

class Derived : Base
{
   void method() in { assert(false); } body {}
}

void main()
{
   Base b = new Derived;
   b.method();
}

But, according to the spec, IIUC, it should successfully pass the check.

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

If I add an explicit empty in-contract to Base.method:
  void method() in{} body{}
then it passes the check.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3722


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code
                 CC|                            |yebblies@gmail.com
           Platform|Other                       |All


--- Comment #1 from yebblies <yebblies@gmail.com> 2011-07-03 04:43:03 EST ---
https://github.com/D-Programming-Language/dmd/pull/192

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3722


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-07-03 02:21:33 PDT ---
https://github.com/D-Programming-Language/dmd/commit/1de48286f27eeb58231ab033d35385f06bf0e578

https://github.com/D-Programming-Language/dmd/commit/f2722bf1b96c024141698edfb01894578590a546

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------