Bug 20502 – Converting std.typecons.RefCounted!T to a string gives T's storage location instead of T's fields when T is a struct without an explicit toString
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-13T18:50:00Z
Last change time
2021-03-02T12:14:13Z
Keywords
pull
Assigned to
No Owner
Creator
Nathan S.
Comments
Comment #0 by n8sh.secondary — 2020-01-13T18:50:00Z
Converting std.typecons.RefCounted!T to a string gives T's storage location instead of T's fields when T is a struct without an explicit toString.
Demonstration:
---
void main()
{
import std.typecons : refCounted;
import std.stdio : writeln;
writeln(123); // "123"
writeln(refCounted(123)); // "123"
struct A { string toString() { return "a"; } }
writeln(A.init); // "a"
writeln(refCounted(A.init)); // "a"
// This one doesn't match:
struct B { int x; }
writeln(B(123)); // "B(123)"
writeln(refCounted(B(123))); // "RefCounted!(B, cast(RefCountedAutoInitialize)0)(RefCountedStore(558C7FFBC660))"
}
---
Comment #1 by dlang-bot — 2020-01-13T18:58:13Z
@n8sh created dlang/phobos pull request #7352 "Fix Issue 20502: Converting std.typecons.RefCounted!T to a string gives T's storage location instead of T's fields when T is a struct without an explicit toString" fixing this issue:
- Fix Issue 20502: Converting std.typecons.RefCounted!T to a string gives T's storage location instead of T's fields when T is a struct without an explicit toString
https://github.com/dlang/phobos/pull/7352
Comment #2 by dlang-bot — 2021-03-02T12:14:13Z
dlang/phobos pull request #7352 "Fix Issue 20502: Converting std.typecons.RefCounted!T to a string gives T's storage location instead of T's fields when T is a struct without an explicit toString" was merged into master:
- f35bff2c1b503f643a4ff292a4cf74b9d44a5c7e by Nathan Sashihara:
Fix Issue 20502: Converting std.typecons.RefCounted!T to a string gives T's storage location instead of T's fields when T is a struct without an explicit toString
https://github.com/dlang/phobos/pull/7352