digitalmars.D - fullyQualifiedName fails on template
- =?UTF-8?B?IsOYaXZpbmQi?= (38/38) Jan 23 2014 Is fullyQualifiedName supposed to work on templates? The
- Dicebot (1/1) Jan 24 2014 https://d.puremagic.com/issues/show_bug.cgi?id=10502
- Timon Gehr (3/5) Jan 24 2014 Compiler bug.
- Dicebot (3/5) Jan 24 2014 More like "Phobos bug that is very hard to fix because of
- Martin Cejp (5/11) Jan 24 2014 The bug hasn't been updated in half a year. Can we help with
- David Nadlinger (5/7) Jan 24 2014 In general, you can't reliably stringify types for use in string
- Martin Cejp (3/5) Jan 24 2014 May I ask why?
- =?UTF-8?B?IsOYaXZpbmQi?= (13/19) Jan 24 2014 Looking at the code, it does not seem like it pays any attention
- Timon Gehr (10/29) Jan 25 2014 alias Seq(T...)=T;
- Dicebot (7/16) Jan 25 2014 It won't work for templated function type though and probably
Is fullyQualifiedName supposed to work on templates? The following fails: struct MsgPack(T ...) { } struct TestPoint { float x, y; } alias TestPack = MsgPack!TestPoint; void main() { import std.traits; import std.stdio; //writeln(fullyQualifiedName!TestPack); //Fails writeln(fullyQualifiedName!(MsgPack!TestPoint)); //Fails } with error: /opt/compilers/dmd2/include/std/traits.d(340): Error: forward reference of variable parentPrefix /opt/compilers/dmd2/include/std/traits.d(501): Error: template instance std.traits.fullyQualifiedNameImplForSymbols!(MsgPack!(TestPoint)) error instantiating /opt/compilers/dmd2/include/std/traits.d(292): instantiated from here: fullyQualifiedNameImplForTypes!(MsgPack!(TestPoint), false, false, false, false) /d112/f728.d(19): instantiated from here: fullyQualifiedName!(MsgPack!(TestPoint)) /opt/compilers/dmd2/include/std/traits.d(292): Error: template instance std.traits.fullyQualifiedNameImplForTypes!(MsgPack!(TestPoint), false, false, false, false) error instantiating /d112/f728.d(19): instantiated from here: fullyQualifiedName!(MsgPack!(TestPoint)) /d112/f728.d(19): Error: template instance std.traits.fullyQualifiedName!(MsgPack!(TestPoint)) error instantiating
Jan 23 2014
On 01/24/2014 03:20 AM, "Øivind" wrote:Is fullyQualifiedName supposed to work on templates?Yes.The following fails:Compiler bug.
Jan 24 2014
On Friday, 24 January 2014 at 09:38:24 UTC, Timon Gehr wrote:More like "Phobos bug that is very hard to fix because of compiler bug"The following fails:Compiler bug.
Jan 24 2014
On Friday, 24 January 2014 at 09:40:32 UTC, Dicebot wrote:On Friday, 24 January 2014 at 09:38:24 UTC, Timon Gehr wrote:The bug hasn't been updated in half a year. Can we help with fixing it? It's quite an issue if you want to copy a method with a mixin and you can't reliably stringify the return type.More like "Phobos bug that is very hard to fix because of compiler bug"The following fails:Compiler bug.
Jan 24 2014
On Friday, 24 January 2014 at 14:08:45 UTC, Martin Cejp wrote:It's quite an issue if you want to copy a method with a mixin and you can't reliably stringify the return type.In general, you can't reliably stringify types for use in string mixins anyway. Just insert ReturnType!(…) or whatever you need directly into your mixin string. Dvid
Jan 24 2014
On Friday, 24 January 2014 at 14:31:01 UTC, David Nadlinger wrote:In general, you can't reliably stringify types for use in string mixins anyway.May I ask why? Anyway, thanks for the workaround.
Jan 24 2014
On Friday, 24 January 2014 at 09:40:32 UTC, Dicebot wrote:On Friday, 24 January 2014 at 09:38:24 UTC, Timon Gehr wrote:Looking at the code, it does not seem like it pays any attention to template parameters at all? I would expect that for a template instantiation A!(B, C) it would resolve parents, etc. for A, B and C in turn.. How would I do that if I were to give it a go? E.g. for a template instance A!(B, C), how do I use __traits or std.traits to get the plain type A, and B and C so I can use e.g. __traits(parent...) to figure out where they come from? That is really all I need. For me C can be defined inside a struct, so (A!(B, C)).stringof is not sufficient.. I would need a result like e.g A!(B, X.C)More like "Phobos bug that is very hard to fix because of compiler bug"The following fails:Compiler bug.
Jan 24 2014
On 01/25/2014 02:06 AM, "Øivind" wrote:On Friday, 24 January 2014 at 09:40:32 UTC, Dicebot wrote:alias Seq(T...)=T; struct A(T...){} struct B{} struct C{} alias T=A!(B,C); static if(is(T==X!Y,alias X,Y...)){ static assert(__traits(isSame, X, A)); static assert(is(Y==Seq!(B,C))); }On Friday, 24 January 2014 at 09:38:24 UTC, Timon Gehr wrote:Looking at the code, it does not seem like it pays any attention to template parameters at all? I would expect that for a template instantiation A!(B, C) it would resolve parents, etc. for A, B and C in turn.. How would I do that if I were to give it a go? E.g. for a template instance A!(B, C), how do I use __traits or std.traits to get the plain type A, and B and C so I can use e.g. __traits(parent...) to figure out where they come from? That is really all I need. For me C can be defined inside a struct, so (A!(B, C)).stringof is not sufficient.. I would need a result like e.g A!(B, X.C)More like "Phobos bug that is very hard to fix because of compiler bug"The following fails:Compiler bug.
Jan 25 2014
On Saturday, 25 January 2014 at 08:53:19 UTC, Timon Gehr wrote:alias Seq(T...)=T; struct A(T...){} struct B{} struct C{} alias T=A!(B,C); static if(is(T==X!Y,alias X,Y...)){ static assert(__traits(isSame, X, A)); static assert(is(Y==Seq!(B,C))); }It won't work for templated function type though and probably some other cases I have forgotten by today. That was the problem locking fullyQualifiedName update as such functionality in Phobos is suppose to be generic. That said, probably adding simple special case for aggregate types is worth it as it seems most common thing to encounter.
Jan 25 2014