Bug 11719 – regression: __traits(parent, T) for function alias

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-10T14:20:00Z
Last change time
2013-12-16T11:12:43Z
Assigned to
nobody
Creator
timothee.cour2

Comments

Comment #0 by timothee.cour2 — 2013-12-10T14:20:21Z
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"); }
Comment #1 by k.hara.pg — 2013-12-10T20:00:47Z
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.