www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Regression] Abstract method cannot have contracts

reply Stewart Gordon <Stewart_member pathlink.com> writes:
Using DMD 0.102, Windows 98SE.

A 'fix' introduced in DMD 0.101 has had an apparently unexpected consequence,
which I 
noticed when a bit of SDWF stopped compiling.

----------
abstract class Qwert {
abstract int yuiop(int asdfg)
in {
assert (asdfg <= 100);
};
}

interface Zcxvb {
int yuiop(int asdfg)
in {
assert (asdfg <= 10);
}
out (result) {
assert (yuiop % 3 == 1);
};
}
----------
D:\My Documents\Programming\D\Tests\bugs\abstract_dbc.d(5): missing body { ... }
after 
in or out
D:\My Documents\Programming\D\Tests\bugs\abstract_dbc.d(15): missing body { ...
} 
after in or out
----------

Missing body?  They're abstract, so of course there's no body.

I've always assumed that contracts were supposed to be allowed in
abstract/interface 
methods.  Even if they have no effect before we have contract inheritance.

Stewart.
Sep 24 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"Stewart Gordon" <Stewart_member pathlink.com> wrote in message
news:cj0q80$2tum$1 digitaldaemon.com...
 I've always assumed that contracts were supposed to be allowed in
 abstract/interface
 methods.  Even if they have no effect before we have contract inheritance.
Well, no. The contract code goes with the function body. Perhaps in the future it could be made to work on interface methods, but not now.
Mar 02 2005
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Walter wrote:
 "Stewart Gordon" <Stewart_member pathlink.com> wrote in message
 news:cj0q80$2tum$1 digitaldaemon.com...
 
I've always assumed that contracts were supposed to be allowed in
abstract/interface
methods.  Even if they have no effect before we have contract inheritance.
Well, no. The contract code goes with the function body.
<snip> The contract code already needs to be separated from the body at compile-time in order to support contract inheritance at all. So disallowing contract code with an abstract method seems an arbitrary restriction. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on on the 'group where everyone may benefit.
Mar 23 2005