June 30, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8326

           Summary: std.string.format results in run-time exception
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: puneet@coverify.org


--- Comment #0 from Puneet Goel <puneet@coverify.org> 2012-06-30 11:19:22 PDT ---
std.string.format throws runtime exception for BigInt and for BitArray types even though writefln works fine. The run-time error says std.format.FormatException@std/format.d(4744): Can't convert std.bigint.BigInt to string: "string toString()" not defined

Here is a small test case:


void main()
{
  import std.stdio;
  import std.string;
  import std.bigint;
  import std.bitmanip;

  BigInt aa = 100;

  BitArray bb;
  bb.init([true, false]);

  writefln("%x", aa);
  writefln("%x", bb);
  writeln(format("%x", aa)); // throws exception
  writeln(format("%x", bb)); // throws exception
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8326


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx


--- Comment #1 from hsteoh@quickfur.ath.cx 2012-10-27 12:14:24 PDT ---
Yeah std.string.format is being deprecated, because it is an inferior version of std.format. Until it is replaced by the latter, using xformat should work (xformat simply calls std.format so it will be identical to writeln & friends).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8326



--- Comment #2 from hsteoh@quickfur.ath.cx 2012-10-27 12:15:25 PDT ---
I meant to paste the modified code:

void main()
{
  import std.stdio;
  import std.string;
  import std.bigint;
  import std.bitmanip;

  BigInt aa = 100;

  BitArray bb;
  bb.init([true, false]);

  writefln("%x", aa);
  writefln("%x", bb);
  writeln(xformat("%x", aa)); // this works
  writeln(xformat("%x", bb)); // this works
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8326


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from hsteoh@quickfur.ath.cx 2013-01-02 10:13:06 PST ---
This bug has been fixed in latest git head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home