Bug 21846 – std.format: provided format string for toString does not work with grouping

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-21T15:41:04Z
Last change time
2021-04-22T09:08:03Z
Keywords
pull
Assigned to
No Owner
Creator
Berni44

Comments

Comment #0 by bugzilla — 2021-04-21T15:41:04Z
unittest { struct S { int a; void toString(void delegate(const(char)[]) sink, string fmt) { auto spec = singleSpec(fmt); sink.formatValue(a, spec); } } S s = S(1); assert(format!"%5,3d"(s) == " 1"); } The reason is, that fmt == "%,35d", which makes the width 5 part of the grouping value.
Comment #1 by dlang-bot — 2021-04-21T15:52:08Z
@berni44 created dlang/phobos pull request #7996 "Fix Issue 21846 - std.format: provided format string for toString does not work with grouping" fixing this issue: - Fix Issue 21846 - std.format: provided format string for toString does not work with grouping https://github.com/dlang/phobos/pull/7996
Comment #2 by dlang-bot — 2021-04-22T09:08:03Z
dlang/phobos pull request #7996 "Fix Issue 21846 - std.format: provided format string for toString does not work with grouping" was merged into master: - 1a5064f2fcd815691dbcc76df61fcb9b5ecd77e9 by berni44: Fix Issue 21846 - std.format: provided format string for toString does not work with grouping https://github.com/dlang/phobos/pull/7996