Bug 23246 – [REG 2.099] std.format ignores non-const toString method of associative array value
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-07-13T18:23:29Z
Last change time
2022-07-13T22:15:41Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2022-07-13T18:23:29Z
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
---
[email protected](12): "[0:const(S)()]" != "[0:S]"
---
As of DMD 2.098.1, the above program compiled and ran to completion without any errors.
Comment #1 by dlang-bot — 2022-07-13T18:52:41Z
@pbackus created dlang/phobos pull request #8507 "Fix 23245, 23246 - std.format regressions" fixing this issue:
- Fix 23246 - std.format ignores non-const toString method of associative array value
https://github.com/dlang/phobos/pull/8507
Comment #2 by dlang-bot — 2022-07-13T22:15:41Z
dlang/phobos pull request #8507 "Fix 23245, 23246 - std.format regressions" was merged into master:
- 223b82ac2602c871b8ca46ed8ce00091f33e0412 by Paul Backus:
Fix 23246 - std.format ignores non-const toString method of associative array value
https://github.com/dlang/phobos/pull/8507