Bug 24075 – Can't use toChars with `ushort` or `ubyte`

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-08-06T16:36:54Z
Last change time
2023-12-30T16:06:35Z
Keywords
pull
Assigned to
No Owner
Creator
Grim Maple

Comments

Comment #0 by grimmaple95 — 2023-08-06T16:36:54Z
There is a weird limitation on `toChars` that only allows it to work with ubyte and uint: ``` ubyte a = 123; writeln(a.toChars!(16)); ``` ``` onlineapp.d(6): Error: none of the overloads of template `std.conv.toChars` are callable using argument types `!(16)(ubyte)` /dlang/dmd/linux/bin64/../../src/phobos/std/conv.d(5710): Candidate is: `toChars(ubyte radix = 10, Char = char, LetterCase letterCase = LetterCase.lower, T)(T value)` with `radix = 16, Char = char, letterCase = LetterCase.lower, T = ubyte` must satisfy one of the following constraints: ` is(immutable(T) == immutable(uint)) is(immutable(T) == immutable(ulong)) radix == 10` ```
Comment #1 by nick — 2023-08-07T13:07:24Z
> that only allows it to work with ubyte and uint I think you meant uint or ulong. Also int and long can only be used when radix is 10.
Comment #2 by dlang-bot — 2023-12-20T15:07:05Z
@eoan-ermine updated dlang/phobos pull request #8866 "Fix issue 24075 - Can't use toChars with `ushort` or `ubyte`" fixing this issue: - Fix issue 24075 - Can't use toChars with ushort or ubyte https://github.com/dlang/phobos/pull/8866
Comment #3 by dlang-bot — 2023-12-30T16:06:35Z
dlang/phobos pull request #8866 "Fix issue 24075 - Can't use toChars with `ushort` or `ubyte`" was merged into master: - ce1da546318a7aac9877b7be5d6fc83735835b9c by Danil Sidoruk: Fix issue 24075 - Can't use toChars with ushort or ubyte https://github.com/dlang/phobos/pull/8866