www.digitalmars.com         C & C++   DMDScript  

D - Two bugs for the price of one ...

the following compiles without warnings on dmd 0.52 alpha.
I believe in the Java semantics, any class that has an abstract method must
be declared abstract AND can not be instantiated.
also the lack of a warning that there is a code path that may cause the
return to be undefined, may be grouped under the var not init-ed class of
complaints/enhancement that I know you are opposed to, but I do believe that
an extra return 0; that never gets called of a throw new Exception('how did
I get Here?'); is better, more robust and less error prone than a func that
just falls out the end.

class Base
 abstract int foo();

class Derv : Base

int func( int a )
 if ( a < 5 ) { return (new Derv()).foo(); }

int main( char[][] args )
 return func( 2 ) + func( 7 );

as expected the result of running this code is `Error: Access Violation`
(might be nice if this was Error: abstract func called, or an abstract
method called exception, not that you should ever be able to create an
instance of an abstract class)

Feb 06 2003