[Issue 11835] Assert not thrown from contract

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 30 17:14:21 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11835



--- Comment #4 from Tomáš Chaloupka <chalucha at gmail.com> 2013-12-30 17:14:17 PST ---
Ok, now I see why it is working like that, but consider this sample:

interface IFoo
{
        void test()
        in
        {
                writeln("IFoo.test");
                assert(false);
        }
}

class Foo : IFoo
{
        void test()
        in
        {
                writeln("Foo.test");
        }
        body{}
}

class Bar : IFoo
{
        void test()
        in
        {
                writeln("Bar.test");
        }
        body{}
}

as it works now it means, that interface contract will never throw an
AssertError, because Foo and Bar tests passes.

What is then the point to define contract in the interface if I have to set the
same in class definitions of that interface?

In upper sample it can be understandable as new "in" contracts are defined, but
if I use just this?:

interface IFoo
{
        void test()
        in
        {
                writeln("IFoo.test");
                assert(false);
        }
}

class Foo : IFoo
{
        void test() { writeln("Foo"); }
}

class Bar : IFoo
{
        void test() { writeln("Bar"); }
}

here I will definitelly expect that contract defined in interface will be used
to check input of actual methods.

It just seems weird to me. For example if I write a library with the public
interface or abstract class and want to check input params of it so when other
project uses it it will check if it is used properly. But as it works now, this
is not possible.

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


More information about the Digitalmars-d-bugs mailing list