Bug 18438 – hasStaticMember fails with a T* while hasMember passes

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-02-14T23:35:40Z
Last change time
2018-03-29T23:53:05Z
Assigned to
No Owner
Creator
Ali Ak

Comments

Comment #0 by ali.akhtarzada — 2018-02-14T23:35:40Z
Seems __traits(hasMember, T*, m) is resolved amicably by the compiler and it tells you if m is a member of T or not. OTOH, hasStaticMember barfs with a compiler error if you give it a T*. Due to the implementation of hasStaticMember, compilation only fails with member fields, not functions. Error: cannot interpret T* at compile time IMO, hasMember and hasStaticMember should either both fail on a T* or both not fail. This fixes the latter if desired, and I'm happy to push a PR and fix as needed if this is the correct direction: https://github.com/aliak00/phobos/commit/3d5b9677944acb7439dd1564fac899400b00de32 (There was a bug in the unittest which I fixed in the same commit as well. If this is not ok, I'm happy to alter as required.)
Comment #1 by github-bugzilla — 2018-03-29T23:53:04Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4e222b856b30a41d330067a2bb5c6cf38a80de1f Fix issue 18438 - Handle T* in hasStaticMember hasMember treats T* as T, so lets make hasStaticMember do the same https://github.com/dlang/phobos/commit/0372d48dc00c2f4e6c7b9fa5ac101a43810e3222 Merge pull request #6179 from aliak00/has-static-member Fix issue 18438 - Handle T* in hasStaticMember like hasMember merged-on-behalf-of: Nathan Sashihara <[email protected]>