Bug 23245 – [REG 2.099] std.format ignores non-const toString method of static array element
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-07-13T18:17:24Z
Last change time
2022-07-13T22:15:40Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2022-07-13T18:17:24Z
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
---
[email protected](12): "[const(S)()]" != "[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:40Z
@pbackus created dlang/phobos pull request #8507 "Fix 23245, 23246 - std.format regressions" fixing this issue:
- Fix 23245 - std.format ignores non-const toString method of static array element
https://github.com/dlang/phobos/pull/8507
Comment #2 by dlang-bot — 2022-07-13T22:15:40Z
dlang/phobos pull request #8507 "Fix 23245, 23246 - std.format regressions" was merged into master:
- e1ba05dab1853478c1a05ed8655df4017fed9ad9 by Paul Backus:
Fix 23245 - std.format ignores non-const toString method of static array element
https://github.com/dlang/phobos/pull/8507