[Issue 2274] all static if typeof seriously wrong

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 7 17:42:27 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2274





------- Comment #4 from 2korden at gmail.com  2008-08-07 19:42 -------
I can't agree with you. The binary generated is perfectly valid. It never
crashes, it behaves just like intended. The fact alone that you expect
different result doesn't mean the executable is broken.

Your static if check is not passed, that's all.

If you expect to see the following output:
test.A:+ test.B:+ test.C:- int:-

then you should change your code. You are not allowed to access non-static data
via class name like this:
bool result = is(typeof(E.toString()) : string); // false unless toString is
static

or like this:
bool result = is(typeof(E.myInt) : int);

You have to create a class instance, first:
auto e = new E();
bool result = is(typeof(e.toString()) : string); // true for any class unless
toString is private

or, better, in one line:
bool result = is(typeof((new E()).toString()) : string);

Note that no allocation will take place in latter case since it is merely a
check.

Shall we consider an issue closed by now?


-- 



More information about the Digitalmars-d-bugs mailing list