www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6910] New: __traits(hasMember, "<name>") does not work, if template has alias param

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6910

           Summary: __traits(hasMember, "<name>") does not work, if
                    template has alias param
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tobias pankrath.net



PST ---
Given this code fragment:

--------------
struct Bag(S...)
{
    alias S Types;
}

template Test(alias i, B)
{
    void fn() {
        foreach(t; B.Types)
        {
            switch(i) {
                case IndexOf!(t, B.Types):
                {
                    pragma(msg, __traits(allMembers, t));
                    pragma(msg, __traits(hasMember, t, "m"));
                    break;
                }
                default: {}
            }
        }
    }
}

struct A
{
    int m;
}


void main()
{

    int i;
    alias Test!(i, Bag!(A)).fn func;
}
----------------------

DMD will output:
----------------------
tuple("m")
false
---------------------

It seems that __traits(hasMember, ..) evaluates to false, despite the fact that
the type 
does have a member "m". However if the template Test does not have an alias
parameter, everything will work just fine.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 08 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6910


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code
           Platform|x86_64                      |All
            Version|D2                          |D1 & D2
         OS/Version|Linux                       |All



I think this is an issue that both of D1 and D2 have.

D2 patch:
https://github.com/D-Programming-Language/dmd/pull/509

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6910


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



00:33:46 PST ---
https://github.com/D-Programming-Language/dmd/commit/6fb5861528c7568d2546774a1c884f99594024c0

https://github.com/D-Programming-Language/dmd/commit/129c1ae7fe50cb3cb9a218e232f42f9a5a987e29

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 14 2011