Bug 13746 – formatValue of delegates with @nogc

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-18T09:13:00Z
Last change time
2015-02-18T03:39:57Z
Assigned to
nobody
Creator
ilyayaroshenko

Comments

Comment #0 by ilyayaroshenko — 2014-11-18T09:13:41Z
unittest { static void func() {} formatTest( &func, "void function()" ); } unittest { void func() @nogc {} formatTest( &func, "@nogc void delegate()" ); } void formatTest(T)(T val, string expected, size_t ln = __LINE__, string fn = __FILE__) { import std.array : appender; import std.conv : text; FormatSpec!char f; auto w = appender!string(); formatValue(w, val, f); enforce!AssertError( w.data == expected, text("expected = `", expected, "`, result = `", w.data, "`"), fn, ln); }
Comment #1 by ilyayaroshenko — 2014-11-18T10:55:44Z
update: unittest { import std.conv : to; int i; int foo(short k) @nogc { return i + k; } int delegate(short) @nogc bar() nothrow { return &foo; } assert(to!string(&bar) == "int delegate(short) @nogc delegate() nothrow"); }
Comment #2 by github-bugzilla — 2014-11-19T18:00:25Z
Comment #3 by github-bugzilla — 2015-02-18T03:39:57Z