Does dmd not always compile all of the source code?
A Guy With a Question
aguywithanquestion at gmail.com
Wed Dec 6 19:19:09 UTC 2017
On Wednesday, 6 December 2017 at 18:09:45 UTC, Steven
Schveighoffer wrote:
> On 12/6/17 12:17 PM, Steven Schveighoffer wrote:
>
>> So why wouldn't the compiler fail? Because it has no idea yet
>> what you mean by Nullable. It doesn't even know if Nullable
>> will be available or not. You could even import Nullable, but
>> Nullable!T may be an error.
>
> To give an example of why the compiler waits until
> instantiation:
>
> class C(T) : T
> {
> void foo() { doesthisexist(); }
> }
>
> class D { void doesthisexist(); }
>
> auto x = new C!D; // OK
> auto y = new C!Object: // fail
>
> -Steve
It also doesn't parse or do semantic checks on unit tests unless
you add the flag...apparently.
This compiles...
unittest
{
WHY DOESNT THE COMPILER FIND A PROBLEM HERE!?
}
It seems D's fast compile times are achieved by skipping semantic
checking and even parsing when it doesn't feel it's needed. I
strongly disagree with this decision. This could leave complex
dormant time bombs that break builds unexpectedly and even
accidentally. It's understandable in certain situations where
there is enough information, but the first step to testing code,
is first making sure it compiles...I don't want the compiler
making decisions on what is worthy to compile. If I pass a d
source file into it, I want to know if it's valid. This is
unfortunate. This might be a deal breaker for me.
More information about the Digitalmars-d-learn
mailing list