Bug 20534 – std.format: %r on boolean gives wrong result

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-26T12:02:17Z
Last change time
2021-04-08T13:36:12Z
Keywords
pull
Assigned to
berni44
Creator
berni44

Comments

Comment #0 by bugzilla — 2020-01-26T12:02:17Z
The output of %r on booleans gives 4 bytes, not only one, because the bool is cast to an int before it is formatted. This is inconsistent with other uses of %r (which is yet undocumented). void main() { import std.format : format; assert(format("%r",false) == "\0"); // fails }
Comment #1 by dlang-bot — 2021-04-08T11:54:05Z
@berni44 created dlang/phobos pull request #7946 "Fix Issue 20534 - std.format: %r on boolean gives wrong result" fixing this issue: - Fix Issue 20534 - std.format: %r on boolean gives wrong result https://github.com/dlang/phobos/pull/7946
Comment #2 by dlang-bot — 2021-04-08T13:36:12Z
dlang/phobos pull request #7946 "Fix Issue 20534 - std.format: %r on boolean gives wrong result" was merged into master: - f455389d7f2da3d8ab506a6b4345ca956a32158a by berni44: Fix Issue 20534 - std.format: %r on boolean gives wrong result https://github.com/dlang/phobos/pull/7946