Thread overview
[Issue 6892] New: Formatted write with specified length of enum member
Feb 28, 2012
Ali Cehreli
Feb 29, 2012
Kenji Hara
Apr 21, 2012
SomeDude
Apr 21, 2012
Ali Cehreli
Apr 23, 2012
Kenji Hara
Apr 23, 2012
Kenji Hara
November 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6892

           Summary: Formatted write with specified length of enum member
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-11-05 04:04:51 PDT ---
import std.stdio, std.traits;
enum Foo { A };
void main() {
    writefln(">%12s<", "A");
    Foo[] foos = [EnumMembers!Foo];
    writefln(">%12s<", foos[0]);
}


Output dmd 2.057head:

>           A<
>A<


Expected output:

>           A<
>           A<

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


Ali Cehreli <acehreli@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli@yahoo.com


--- Comment #1 from Ali Cehreli <acehreli@yahoo.com> 2012-02-27 22:45:48 PST ---
The following must be another manifestation of the same bug:

import std.stdio;

void main()
{
    enum E { e0 }

    foreach (format; [ "%s", "%d", "%u", "%3.7g", "%x", "%b" ]) {
        writefln(format, E.e0);
    }
}

Outputs:

e0
e0
e0
e0
e0
e0

Ali

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-02-28 17:12:09 PST ---
https://github.com/D-Programming-Language/phobos/pull/465

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



--- Comment #3 from github-bugzilla@puremagic.com 2012-03-01 09:20:32 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/b5256c57f64fa823ca8ba200d343674d6556c75c Merge pull request #465 from 9rnsr/fix6892

Issue 6892 - Formatted write with specified length of enum member

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



--- Comment #4 from github-bugzilla@puremagic.com 2012-03-08 22:54:49 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/12571977d821a2e7e7a799012baea3e8f73dee0d fix Issue 6892 - Formatted write with specified length of enum member

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


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #5 from SomeDude <lovelydear@mailmetrash.com> 2012-04-20 17:12:03 PDT ---
On 2.059 Win32, the original test passes but the test of comment 1 throws an exception:

PS E:\DigitalMars\dmd2\samples> rdmd bug.d
e0
0
0
std.format.FormatException@E:\DigitalMars\dmd2\windows\bin\..\..\src\phobos\std\format.d(1178):
integral

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



--- Comment #6 from Ali Cehreli <acehreli@yahoo.com> 2012-04-20 18:55:09 PDT ---
The problem at comment 5 can be reduced to this:

import std.stdio;

void main()
{
    writefln("%f", 42); // COMPILATION ERROR
}

It looks like an integral cannot be matched to a floating point format specifier. (The same problem with "%g", etc.)

I have mixed feelings about this. Although 42 is definitely not a floating point type, it is implicitly converted to one according to language rules.

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



--- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> 2012-04-22 17:55:41 PDT ---
(In reply to comment #6)
> The problem at comment 5 can be reduced to this:
> 
> import std.stdio;
> 
> void main()
> {
>     writefln("%f", 42); // COMPILATION ERROR
> }
> 
> It looks like an integral cannot be matched to a floating point format specifier. (The same problem with "%g", etc.)
> 
> I have mixed feelings about this. Although 42 is definitely not a floating point type, it is implicitly converted to one according to language rules.

This is not allowed in current std.format implementation.

Original issue was already fixed, so I'll close this issue. If you think integer value should be formatted with "%f", please open new enhancement request.

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


Kenji Hara <k.hara.pg@gmail.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------