[Issue 23246] New: [REG 2.099] std.format ignores non-const toString method of associative array value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 13 18:23:29 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23246

          Issue ID: 23246
           Summary: [REG 2.099] std.format ignores non-const toString
                    method of associative array value
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

As of DMD 2.099.1, the following program fails with an AssertError at runtime:

---
struct S
{
    string toString() { return "S"; }
}

void main()
{
    import std.format, std.stdio;

    S[int] s = [0: S()];
    assert(format("%s", s[0]) == "S"); // ok
    assert(format("%s", s) == "[0:S]"); // fails
}
---

The error message is

---
core.exception.AssertError at onlineapp.d(12): "[0:const(S)()]" != "[0:S]"
---

As of DMD 2.098.1, the above program compiled and ran to completion without any
errors.

--


More information about the Digitalmars-d-bugs mailing list