[Issue 23238] New: Cannot write a const Nullable(T, T nullValue)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 11 02:02:11 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23238
Issue ID: 23238
Summary: Cannot write a const Nullable(T, T nullValue)
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: regression
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: kirsybuu at gmail.com
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`
--
More information about the Digitalmars-d-bugs
mailing list