D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
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
Summary: Converting std.typecons.RefCounted!T to a string gives T's storage location i...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-01-13 18:50 UTC by Nathan S.
Modified: 2021-03-02 12:14 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nathan S. 2020-01-13 18:50:00 UTC
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 Dlang Bot 2020-01-13 18:58:13 UTC
@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 Dlang Bot 2021-03-02 12:14:13 UTC
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