[Issue 11719] New: regression: __traits(parent, T) for function alias
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 10 14:20:33 PST 2013
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 at puremagic.com
ReportedBy: timothee.cour2 at gmail.com
--- Comment #0 from Timothee Cour <timothee.cour2 at 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: -------
More information about the Digitalmars-d-bugs
mailing list