Does dmd not always compile all of the source code?

A Guy With a Question aguywithanquestion at gmail.com
Wed Dec 6 17:04:06 UTC 2017


On Wednesday, 6 December 2017 at 16:49:51 UTC, A Guy With a 
Question wrote:
>> module grrr.grr;
>>
>> abstract class Test(T)
>> {
>> private:
>>     T thing;
>>
>> public:
>>     this(T theThing)
>>     {
>>         thing = theThing;
>> 	thisdoesnotexist(); // expect compiler error right here!!!!
>>     }
>> }
>>
>> ...but this compiles just fine.
>
> It does produce there error when I do this:
>
> class Test2
>    : Test!int
> {
>     this(int thing)
>     {
> 	super(thing);
>     }
> }

Another example:

interface ITest(T)
{
    @property
    Nullable!T value();	// have not imported Nullable. Should fail.
}

compiles...

Fails when this happens:

class Test
    : ITest!int
{
    @property
    Nullable!int value() { return nullable(0); }
}


I really do think, regardless of if this is considered a template 
expansion, that dmd should be catching these obvious errors. When 
one writes interfaces and abstract classes they are generally not 
ready to implement the end class yet. And getting a ton of errors 
at once when that occurs is really hard to deal with. I really 
don't understand why the compiler would have issues with this.


More information about the Digitalmars-d-learn mailing list