https://issues.dlang.org/show_bug.cgi?id=16201
--- Comment #4 from Andrei Alexandrescu <and...@erdani.com> --- Sorry for being unclear. It's a superset, not a dupe of 14835. Consider: void fun(T)(T obj) { static if (!hasMember(T, "gun")) throw new Exception("No gun"); obj.gun; } This code should just work. --