[Issue 18438] New: hasStaticMember fails with a T* while hasMember passes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 14 23:35:40 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18438

          Issue ID: 18438
           Summary: hasStaticMember fails with a T* while hasMember passes
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: ali.akhtarzada at gmail.com

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.)

--


More information about the Digitalmars-d-bugs mailing list