Compiling with unknown class gives no error
xporg.roso at gmail.com
Mon Mar 17 23:56:09 PDT 2014
On Monday, 17 March 2014 at 22:44:00 UTC, bearophile wrote:
>> Compiling this with dmd/ldc will procude no error whatsoever,
>> not even a warning (with -w/-wi enabled). It will only trigger
>> a compile error if the operator is called at some point.
>> How come? Obviously if the class does not exist the compiler
>> shouldn't be able to determine the return value of the
>> overloaded operator.
> Similar questions are better asked in D.learn.
> opBinary is not a method, it's a method template. So until you
> instantiate it, it doesn't actually exist. For some reasons for
> templates like C++/D ones you can't perform a full analysis of
> un-instantiated templated code. Time ago some people have asked
> for a partial analysis of template code, but Andrei was against
> Extra note: don't end D class definitions (and structs/enums)
> with a semicolon.
Fair enough. Thanks dude!
More information about the digitalmars-d-ldc