www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23245] New: [REG 2.099] std.format ignores non-const toString

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

          Issue ID: 23245
           Summary: [REG 2.099] std.format ignores non-const toString
                    method of static array element
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla 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;

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

The error is

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

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

--
Jul 13 2022