www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14988] New: Looks like inconsistent error report for the

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

          Issue ID: 14988
           Summary: Looks like inconsistent error report for the pointless
                    in-contract definition
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

Compiler reports an error for Foo1.foo, but not for Foo2.foo.

class Obj1
{
    string foo() { return ""; }
}

class Obj2
{
    string foo();
}

class Foo1 : Obj1
{
    // Error: function test.Foo1.foo cannot have an in contract
    //        when overriden function test.Obj1.foo does not have an in
contract
    override string foo()
    in { }
    body
    {
        return "foo";
    }
}

class Foo2 : Obj2
{
    // no error
    override string foo()
    in { }
    body
    {
        return "foo";
    }
}

----

The original mention is here:
http://forum.dlang.org/post/ms0uh4$24i6$1 digitalmars.com

With 2.067.x, following code had worked without any errors, but with 2.068.1,
it makes an error.

class Foo
{
    override string toString()
    in { }
    body
    {
        return "foo";
    }
}

That's introduced by the druntime change that to directly use object.d than
object.di file.

--
Aug 31 2015