Skip to content

Commit

Permalink
Merge pull request #4904 from MartinNowak/fix16661
Browse files Browse the repository at this point in the history
fix Issue 16661 - failing dstring/wstring format string
  • Loading branch information
yebblies committed Nov 17, 2016
2 parents 8b1a270 + ce85fd6 commit 9707f00
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -6479,6 +6479,13 @@ immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args) if (isSomeChar
assert(is(typeof(format("happy"d)) == dstring));
}

// https://issues.dlang.org/show_bug.cgi?id=16661
@safe unittest
{
assert(format("%.2f"d, 0.4) == "0.40");
assert("%02d"d.format(1) == "01"d);
}

/*****************************************************
* Format arguments into buffer $(I buf) which must be large
* enough to hold the result. Throws RangeError if it is not.
Expand Down Expand Up @@ -6570,7 +6577,7 @@ char[] sformat(Char, Args...)(char[] buf, in Char[] fmt, Args args)
* the difference between the starts of the arrays
*/
@trusted private pure nothrow @nogc
ptrdiff_t arrayPtrDiff(const void[] array1, const void[] array2)
ptrdiff_t arrayPtrDiff(T)(const T[] array1, const T[] array2)
{
return array1.ptr - array2.ptr;
}

0 comments on commit 9707f00

Please sign in to comment.