Bug 5718 – Can't demangle symbol defined inside unittest block
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-03-07T20:11:00Z
Last change time
2015-06-09T05:15:13Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2011-03-07T20:11:36Z
This worked on 2.050, but fails on 2.052:
---------------------
// demangleUnittestIdent.d
import std.stdio, std.traits, std.demangle;
unittest
{
int foo;
writeln( demangle( mangledName!foo ) );
}
void main(){}
---------------------
>dmd demangleUnittestIdent.d -unittest
2.050 result: void demangleUnittestIdent.__unittest1() . int foo
2.052 result: nt11__unittest1FZv59__T5DummyS46_D21demangleUnittestIdent11__unittest1FZv3fooi
Comment #1 by bus_dbugzilla — 2011-03-07T20:44:11Z
The regression occurred in 2.051 when the manged name of 'foo' in the example changed from:
_D21demangleUnittestIdent11__unittest1FZv3fooi
to:
nt11__unittest1FZv59__T5DummyS46_D21demangleUnittestIdent11__unittest1FZv3fooi
Ie, the following was prepended to the old manged name:
nt11__unittest1FZv59__T5DummyS46
Manually passing the *old* mangled name to demangle in 2.051/2.052 results in a successfully demangled name.
Comment #2 by bugzilla — 2012-01-31T01:55:27Z
This appears to be a problem with std.traits.mangledName, as:
import std.stdio, std.traits, std.demangle;
unittest
{
int foo;
writeln( foo.mangleof );
writeln( mangledName!foo );
}
void main(){}
prints:
_D3foo11__unittest1FZv3fooi
0__T5DummyS27_D3foo11__unittest1FZv3fooi
Comment #3 by k.hara.pg — 2012-01-31T06:54:32Z
std.traits.mangledName is a workaround for old dmd bugs.
Now built-in mangleof property almost works correctly, so deprecating it is better.
Comment #4 by bugzilla — 2012-01-31T15:47:41Z
Ok, can you do a pull request for deprecating it, and then we can close this?
Comment #5 by k.hara.pg — 2012-02-01T07:44:09Z
(In reply to comment #4)
> Ok, can you do a pull request for deprecating it, and then we can close this?
Sorry, I had mistaken. std.traits.mangledName has an extra feature against the built-in mangleof property. It returns a pseudo mangled name from given template symbol.
// from unittest
assert(mangledName!mangledName == "3std6traits11mangledName");
It is useful for getting unique string from template symbol, even if std.demangle.demangle() cannot demangle it.
Therefore, now I cannot recommend to deprecate it.
But we can fix the original issue. Please merge following pull:
https://github.com/D-Programming-Language/phobos/pull/414
Comment #6 by bugzilla — 2012-02-01T14:26:53Z
That pull fixes it.
Comment #7 by github-bugzilla — 2012-02-01T14:32:50Z