Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix offending unittest, regarding formatting delegates. #7771

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -2130,7 +2130,12 @@ void formatValue(Writer, T, Char)(auto ref Writer w, auto ref T val, scope const
}
}

/// Delegates are formatted by `ReturnType delegate(Parameters) FunctionAttributes`
/**
* Delegates are formatted by `ReturnType delegate(Parameters) FunctionAttributes`
*
* Known Bug: Function attributes are not always correct.
* See $(BUGZILLA 18269) for more details.
*/
@safe unittest
{
import std.conv : to;
Expand Down Expand Up @@ -4824,6 +4829,9 @@ if (isSIMDVector!V)

/*
Delegates are formatted by `ReturnType delegate(Parameters) FunctionAttributes`

Known bug: Because of issue https://issues.dlang.org/show_bug.cgi?id=18269
the FunctionAttributes might be wrong.
*/
private void formatValueImpl(Writer, T, Char)(auto ref Writer w, scope T, scope const ref FormatSpec!Char f)
if (isDelegate!T)
Expand All @@ -4834,7 +4842,14 @@ if (isDelegate!T)
@safe unittest
{
void func() @system { __gshared int x; ++x; throw new Exception("msg"); }
version (linux) formatTest( &func, "void delegate() @system" );
version (linux)
{
import std.array : appender;
FormatSpec!char f;
auto w = appender!string();
formatValue(w, &func, f);
assert(w.data.length >= 15 && w.data[0 .. 15] == "void delegate()");
}
}

@safe pure unittest
Expand Down