Hey,
this code returns true:
class Test {
void opDispatch( string s, Args ... )( auto ref Args args )
if( false )
{
}
}
pragma( msg, __traits( hasMember, Test, "WHATEVEVER_DUDE" ) );
Also, stuff like traits compiles and getMember (but that only in compiles) behave the same.
Comment #1 by czdanol — 2014-08-07T20:04:47Z
Ah, and that Args ... has to be there, too. Just saying.
Comment #2 by default_357-line — 2020-02-12T09:09:49Z
Just ran into this. Seems to only happen if there's arguments, if you take out Args it correctly determines that opDispatch never matches.
Comment #3 by default_357-line — 2020-02-12T09:15:17Z
Workaround: it works if you use Test.init instead of Test
Comment #4 by default_357-line — 2020-02-12T09:22:21Z
Note: it's actually not possible rn with `hasMember` to check if a *type* has a member without also (brokenly) checking if an expression of the type has the member. The only option is `__traits(compiles, Type.member)`.
Comment #5 by robert.schadek — 2024-12-13T18:23:39Z