www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11719] New: regression: __traits(parent, T) for function alias

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

           Summary: regression: __traits(parent, T) for function alias
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timothee.cour2 gmail.com


--- Comment #0 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-10
14:20:21 PST ---
works in 2.064.2, compile failure in git head

module bugs.bug_2013_12_10_14_12_40;
import std.traits:isCallable;
int fun0(int x=0){return x;}
int fun(int x){return x;}

template Stringof(alias T) {
  static if (!isCallable!T) enum Stringof = T.stringof;
  else enum Stringof = __traits(identifier, T);
}

template packageName(alias T)
{
  static if (!isCallable!T && Stringof!T.length >= 9 && Stringof!T[0..8] ==
"package ")
  {
    static if (is(typeof(__traits(parent, T))))
    {
      enum packageName = packageName!(__traits(parent, T)) ~ '.' ~
Stringof!T[8..$];
    }
    else
    {
      enum packageName = Stringof!T[8..$];
    }
  }
  else static if (is(typeof(__traits(parent, T))))
    alias packageName!(__traits(parent, T)) packageName;
  else
    static assert(false, Stringof!T ~ " has no parent");
}

void main(){
  assert(packageName!fun0=="bugs");
  assert(packageName!fun=="bugs");
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11719



--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-12-10 20:00:47 PST ---
This is an intended change introduced by fixing issue 9081.

If you replace two
  is(typeof(__traits(parent, T)))
to
  __traits(compiles, __traits(parent, T)))

Then the OP code will work.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11719


Walter Bright <bugzilla digitalmars.com> changed:

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


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 16 2013