[Issue 20502] New: 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
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 13 18:50:00 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20502
Issue ID: 20502
Summary: 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
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
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))"
}
---
--
More information about the Digitalmars-d-bugs
mailing list