Bug 23238 – Cannot write a const Nullable(T, T nullValue)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-07-11T02:02:11Z
Last change time
2022-12-30T23:40:57Z
Keywords
pull
Assigned to
No Owner
Creator
kirsybuu

Comments

Comment #0 by kirsybuu — 2022-07-11T02:02:11Z
The following code does not compile anymore. It worked in 2.097.2, and broke by 2.099 but possibly earlier. import std.stdio, std.typecons; void main() { const Nullable!(ulong, 0) x = 1; writeln(x); } The error (compiled using DMD 2.100.0), with all but the struct overload omitted for brevity: /src/phobos/std/format/write.d(1239): Error: none of the overloads of template `std.format.internal.write.formatValueImpl` are callable using argument types `!()(LockingTextWriter, const(Nullable!(ulong, 0LU)), const(FormatSpec!char))` [omitted] /src/phobos/std/format/internal/write.d(2665): `formatValueImpl(Writer, T, Char)(auto ref Writer w, auto ref T val, ref scope const FormatSpec!Char f)` with `Writer = LockingTextWriter, T = const(Nullable!(ulong, 0LU)), Char = char` whose parameters have the following constraints: `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` ` is(T == struct) or: is(T == union) > hasToString!(T, Char) or: > !is(BuiltinTypeOf!T) - !is(T == enum) ` `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` [omitted] /src/phobos/std/format/write.d(1239): All possible candidates are marked as `deprecated` or `@disable` Tip: not satisfied constraints are marked with `>` /src/phobos/std/format/write.d(632): Error: template instance `std.format.write.formatValue!(LockingTextWriter, const(Nullable!(ulong, 0LU)), char)` error instantiating /src/phobos/std/stdio.d(1710): instantiated from here: `formattedWrite!(LockingTextWriter, char, const(Nullable!(ulong, 0LU)))` /src/phobos/std/stdio.d(4227): instantiated from here: `write!(const(Nullable!(ulong, 0LU)), char)` nullable_write.d(4): instantiated from here: `writeln!(const(Nullable!(ulong, 0LU)))` It is also not possible to call toString() manually on x. I get this error: nullable_write.d(4): Error: none of the overloads of template `std.typecons.Nullable!(ulong, 0LU).Nullable.toString` are callable using argument types `!()() const` /src/phobos/std/typecons.d(3780): Candidate is: `toString()` nullable_write.d(4): All possible candidates are marked as `deprecated` or `@disable`
Comment #1 by wolframw — 2022-08-25T21:08:36Z
Same problem for NullableRef: import std.stdio, std.typecons; void main() { const NullableRef!(ulong) x = new ulong(1); writeln(x); }
Comment #2 by dlang-bot — 2022-08-25T21:59:47Z
@wolframw created dlang/phobos pull request #8545 "Fix issue 23238 - Cannot write a const Nullable(T, T nullValue)" fixing this issue: - fix issue 23238 - Cannot write a const Nullable(T, T nullValue) https://github.com/dlang/phobos/pull/8545
Comment #3 by dlang-bot — 2022-09-01T20:16:22Z
@wolframw updated dlang/phobos pull request #8552 "Fix Issue 23301 - Dlang website (doc) bug: std_experimental_checkedint.html" fixing this issue: - fix issue 23238 - Cannot write a const Nullable(T, T nullValue) - Merge pull request #8545 from wolframw/fix_23238 Fix issue 23238 - Cannot write a const Nullable(T, T nullValue) https://github.com/dlang/phobos/pull/8552
Comment #4 by dlang-bot — 2022-09-10T13:23:42Z
@MartinNowak created dlang/phobos pull request #8563 "merge stable" fixing this issue: - fix issue 23238 - Cannot write a const Nullable(T, T nullValue) - Merge pull request #8545 from wolframw/fix_23238 Fix issue 23238 - Cannot write a const Nullable(T, T nullValue) https://github.com/dlang/phobos/pull/8563
Comment #5 by ibuclaw — 2022-12-30T23:40:57Z