Inconsistency between `AllMembers` and `hasMember`

drug drug2004 at bk.ru
Sat Nov 17 21:33:37 UTC 2018


On 18.11.2018 0:09, Adam D. Ruppe wrote:
> On Saturday, 17 November 2018 at 20:54:24 UTC, drug wrote:
>> https://run.dlang.io/is/IygU5D
>>
>> AllMembers states that struct S contains "this" member, but hasMember 
>> negates it. Is it bug or misusing?
> 
> I'm not sure what it is supposed to do, but since this is kinda special 
> - it is a keyword for the constructor - I wouldn't expect it to be 
> accessible this way in any reliable manner...
Well, this is another question. I mean that if AllMembers returns 
something it should exist. If it is special member and can not be 
accesible AllMembers shouldn't return it.

Another problem I'm trying to resolve is that if I define struct S 
outside of unittest or inside of unittest but using static qualifier 
AllMembers does not return "this". Also if struct S do not have methods 
AllMembers also doesn't return "this". It looks strange for me, but 
first of all it complicates my code.


More information about the Digitalmars-d-learn mailing list