void fun(T)(T obj) {static if (!hasMember(T, "gun")) throw new Exception("No gun");obj.gun; }Call with something that doesn't have a gun member, and even without the reachability warnings (no -w switch), it doesn't compile. However, with an else clause, it would compile.
I might be stepping on a land mine by bringing it up, but isn't this sort of thing what contracts are for?
-Wyatt