Permalink
Browse files

Merge pull request #532 from 9rnsr/fix_pointer_fmt

Issue 7869 - Cannot format pointer of struct has toString member function
  • Loading branch information...
2 parents eec8360 + 9e37c2a commit d862f1f0787a1b69d44e584dbd9d0f0b96fba701 @WalterBright WalterBright committed Apr 9, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 std/format.d
View
@@ -2469,7 +2469,7 @@ unittest
Pointers are formatted as hex integers.
*/
void formatValue(Writer, T, Char)(Writer w, T val, ref FormatSpec!Char f)
-if (!hasToString!(T, Char) && isPointer!T)
+if (/*!hasToString!(T, Char) && */isPointer!T)
{
if (val is null)
put(w, "null");
@@ -2512,6 +2512,19 @@ unittest
formatTest( q, "FFEECCAA" );
}
+unittest
+{
+ struct S
+ {
+ string toString(){ return ""; }
+ }
+ S* p = null;
+ formatTest( p, "null" );
+
+ S* q = cast(S*)0xFFEECCAA;
+ formatTest( q, "FFEECCAA" );
+}
+
/**
Delegates are formatted by 'Attributes ReturnType delegate(Parameters)'
*/

0 comments on commit d862f1f

Please sign in to comment.