Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looks like inconsistent error report for the pointless in-contract definition #19035

Open
dlangBugzillaToGithub opened this issue Aug 31, 2015 · 5 comments

Comments

@dlangBugzillaToGithub
Copy link

Kenji Hara (@9rnsr) reported this on 2015-08-31T15:10:19Z

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

CC List

Description

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.
@dlangBugzillaToGithub
Copy link
Author

doob (@jacob-carlborg) commented on 2015-09-01T06:29:52Z

I wouldn't say the in-contract is pointless, it's a minimal test case. The original code of course has code in the in-contract.

@dlangBugzillaToGithub
Copy link
Author

dfj1esp02 commented on 2015-09-01T08:08:46Z

See also http://forum.dlang.org/post/cokicokwqnscaktxifze@forum.dlang.org

@dlangBugzillaToGithub
Copy link
Author

dlang-bugzilla (@CyberShadow) commented on 2015-09-01T12:15:38Z

(In reply to Kenji Hara from comment #0)
> Compiler reports an error for Foo1.foo, but not for Foo2.foo.

FWIW - before DMD commit 0ab7722db17351cc8db67f54f36cdb85387bd1d7, the code compiled successfully.

@dlangBugzillaToGithub
Copy link
Author

dlang-bugzilla (@CyberShadow) commented on 2015-09-01T12:16:34Z

Sorry, I meant DMD commit https://github.com/D-Programming-Language/dmd/commit/697c5d566892e3fa686be77ac7cd9d3277c7876b

@dlangBugzillaToGithub
Copy link
Author

dlang-bugzilla (@CyberShadow) commented on 2015-09-01T12:18:06Z

> Issue 6242 - Disallow inoperant "in" contracts 

No problem here I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant