On Wednesday, 26 November 2014 at 09:38:11 UTC, bearophile wrote:
Bear Cherian:
Class MyClass{
this(){}
void someFunction(){
//body
}
}
And in my app I had something like
MyClass classObject;
classObject.someFunction();
When I compile, no warnings or errors.
If you compile that code (with lowercase Class) with -O the
compiler finds the bug:
class MyClass {
this() {}
void someFunction() {
//body
}
}
void main() {
MyClass classObject;
classObject.someFunction;
}
test.d(11,5): Error: null dereference in function _Dmain
But in more complex cases the compiler doesn't.
Bye,
bearophile
Yes, the capital C was a typo.
I still think this shouldn't be an optimization. Maybe I'm just
used to Java, as this would be a compile error by default.