Here's the code: ----- struct Struct(T) { static if (is(typeof(T.nan))) { static const is_fptype = true; } else { static const is_fptype = false; } static if(typeof(*this).is_fptype) //static if((typeof(*this)).is_fptype) //<- fixes it { pragma(msg, "T is " ~ T.stringof); pragma(msg, typeof(*this).stringof ~ " is fp type"); } else { pragma(msg, "T is " ~ T.stringof); pragma(msg, typeof(*this).stringof ~ " is NOT fp type"); } } alias Struct!(float) Sf; alias Struct!(int) Si; ------- From compiling that I get the output: """ T is float Struct!(float) is fp type T is int Struct!(float) is fp type """ The output expected is: """ T is float Struct!(float) is fp type T is int Struct!(int) is NOT fp type """ And that is the output you get if you stick extra parentheses around (typeof(*this)). This was tested on D1.033. Possibly related to: * http://d.puremagic.com/issues/show_bug.cgi?id=2219 * http://d.puremagic.com/issues/show_bug.cgi?id=2154
Added 1.033 to the list of versions and updated the bug to reference it.
Also possibly related to: http://d.puremagic.com/issues/show_bug.cgi?id=2359 The various typeof(this) bugs seems appear in 1.032 and onward, and not be present in 1.031 and earlier. The changelog for 1.032 lists several items relating to typeof, so it's reasonable to assume that one of the fixes introduced this bug.
This was fixed in 1.039/2.023, but not listed in the changelog. (it's the same root cause as bug 2527).