Bug 10502 – Can't get fullyQualifiedName of a templated struct

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-29T09:57:00Z
Last change time
2017-07-15T02:57:19Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
develop32
Depends on
12077, 12264

Comments

Comment #0 by develop32 — 2013-06-29T09:57:06Z
void main() { struct Data(T) { T[16] stuff; } import std.traits; auto name = fullyQualifiedName!(Data!long); } Currently this or anything similar does not work. Compiler complaints about "forward reference of variable parentPrefix" in std.traits (300).
Comment #1 by develop32 — 2013-06-29T10:04:15Z
(In reply to comment #0) > void main() > { > struct Data(T) > { > T[16] stuff; > } > > import std.traits; > auto name = fullyQualifiedName!(Data!long); > } > > Currently this or anything similar does not work. Compiler complaints about > "forward reference of variable parentPrefix" in std.traits (300). Its not about structs, any template does not work, be that class, struct or function. Am I missing something?
Comment #2 by public — 2013-06-29T10:12:46Z
It was an oversight when extending fullyQualifiedName for wider usage. Implementation for template types is currently discussed (there are lot of tricky parts in it). You can still use fullyQualifiedName!Data and add template parameter to string representation manually if it absolutely needed as a temporary workaround.
Comment #3 by k.hara.pg — 2014-02-23T00:21:47Z
To improve fullyQualifiedName, fixing compiler issue 12077 is necessary. After fixing the compiler bug, adding specialized fullyQualifiedNameImplForSymbols should fix the issue. private template fqnTuple(T...) { static if (T.length == 0) enum fqnTuple = ""; else static if (T.length == 1) enum fqnTuple = fullyQualifiedName!(T[0]); else enum fqnTuple = fullyQualifiedName!(T[0]) ~ ", " ~ fqnTuple!(T[1 .. $]); } // construct "Base!(Args)" for the instantiated types and symbols private template fullyQualifiedNameImplForSymbols(alias T : Base!Args, alias Base, Args...) { enum parentPrefix = fullyQualifiedNameImplForSymbols!(__traits(parent, Base)) ~ '.'; enum fullyQualifiedNameImplForSymbols( = parentPrefix ~ __traits(identifier, Base) ~ "!(" ~ fqnTuple!Args ~ ")"; } private template fullyQualifiedNameImplForSymbols(alias T) { .... }
Comment #4 by k.hara.pg — 2014-02-26T00:22:30Z
Comment #5 by github-bugzilla — 2014-02-27T05:03:26Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/2c67d9a71a00a0bf9a00e96ea83f6614714f8b5a fix Issue 10502 - Can't get fullyQualifiedName of a templated struct https://github.com/D-Programming-Language/phobos/commit/da69d207f482449172987928d4b6e2e989897c00 Merge pull request #1967 from 9rnsr/fix10502 Issue 10502 - Can't get fullyQualifiedName of a templated struct
Comment #6 by dlang-bugzilla — 2017-07-15T02:57:19Z
*** Issue 12867 has been marked as a duplicate of this issue. ***