[Issue 17269] New: formattedWrite of struct with Nullable value fails
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Mar 21 03:33:53 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17269
Issue ID: 17269
Summary: formattedWrite of struct with Nullable value fails
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: chalucha at gmail.com
This code fails (dmd-2.072.2):
import std.stdio;
import std.array;
import std.format;
import std.typecons;
struct Foo
{
Nullable!string bar;
}
void main()
{
Foo f;
auto ap = appender!string;
formattedWrite(ap, "%s", f);
writeln(ap.data);
}
core.exception.AssertError@/usr/include/dmd/phobos/std/typecons.d(2309): Called
`get' on null Nullable!string.
----------------
??:? _d_assert_msg [0x4503a6]
??:? std.typecons.Nullable!(immutable(char)[]).Nullable.getinout(pure nothrow
ref @property @nogc @safe inout(immutable(char)[]) function()) [0x4443a1]
??:? pure @safe void
std.format.formatElement!(std.array.Appender!(immutable(char)[]).Appender,
std.typecons.Nullable!(immutable(char)[]).Nullable,
char).formatElement(std.array.Appender!(immutable(char)[]).Appender,
std.typecons.Nullable!(immutable(char)[]).Nullable, ref
std.format.FormatSpec!(char).FormatSpec) [0x445bbc]
??:? pure @safe void
std.format.formatValue!(std.array.Appender!(immutable(char)[]).Appender,
nullableformat.Foo,
char).formatValue(std.array.Appender!(immutable(char)[]).Appender, ref
nullableformat.Foo, ref std.format.FormatSpec!(char).FormatSpec) [0x444d08]
??:? pure void
std.format.formatGeneric!(std.array.Appender!(immutable(char)[]).Appender,
nullableformat.Foo,
char).formatGeneric(std.array.Appender!(immutable(char)[]).Appender,
const(void)*, ref std.format.FormatSpec!(char).FormatSpec) [0x444ca0]
??:? pure @safe uint
std.format.formattedWrite!(std.array.Appender!(immutable(char)[]).Appender,
char,
nullableformat.Foo).formattedWrite(std.array.Appender!(immutable(char)[]).Appender,
const(char[]), nullableformat.Foo) [0x444c3f]
??:? _Dmain [0x44427d]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x451277]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) [0x4511a3]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll() [0x45121c]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) [0x4511a3]
??:? _d_run_main [0x451107]
??:? main [0x44ef57]
??:? __libc_start_main [0xe4ccf400]
--
More information about the Digitalmars-d-bugs
mailing list