www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4704] New: Problems with aa.byValue()

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4704

           Summary: Problems with aa.byValue()
           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



This correct D2 program:


import std.stdio: writeln;
void main() {
    int[int] aa = [1:2, 3:4, 5:6];
    auto vals = aa.byValue();
    foreach (v; vals)
        writeln(v);
}


Outputs with dmd 2.048:
2
4
6

-------------------

But this other program:


import std.stdio: writeln;
void main() {
    int[int] aa = [1:2, 3:4, 5:6];
    auto vals = aa.byValue();
    writeln(vals);
}


writeln() seems unable to print them:

...\dmd\src\phobos\std\format.d(1364): Error: template
std.format.formatValue(Writer,T,Char) if (is(const(T) == const(void[]))) does
not match any function template declaration
...\dmd\src\phobos\std\format.d(1364): Error: template
std.format.formatValue(Writer,T,Char) if (is(const(T) == const(void[]))) cannot
deduce template function from argument types !()(LockingTextWriter,int
delegate(int delegate(ref int) dg),FormatSpec!(immutable(char)))
...\dmd\src\phobos\std\format.d(305): Error: template instance
std.format.formatGeneric!(LockingTextWriter,int delegate(int delegate(ref int)
dg),immutable(char)) error instantiating
...\dmd\src\phobos\std\stdio.d(595):        instantiated from here:
formattedWrite!(LockingTextWriter,immutable(char),int delegate(int delegate(ref
int) dg))
...\dmd\src\phobos\std\stdio.d(1372):        instantiated from here: write!(int
delegate(int delegate(ref int) dg),char)
test.d(6):        instantiated from here: writeln!(int delegate(int
delegate(ref int) dg))

-------------------

And the array() of dmd 2.048 seems unable to create an array (maybe this is
already fixed in SVN):


import std.array: array;
void main() {
    int[int] aa = [1:2, 3:4, 5:6];
    auto vals = aa.byValue();
    int[] avals = array(vals);
}


test.d(5): Error: template std.array.array(Range) if (isInputRange!(Range))
does not match any function template declaration
test.d(5): Error: template std.array.array(Range) if (isInputRange!(Range))
cannot deduce template function from argument types !()(int delegate(int
delegate(ref int) dg))


Similar problems are present with .byKey().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 21 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4704


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm gmail.com



The 2nd program now (2.052) prints

    int delegate(int delegate(ref int))

while the 3rd program now works correctly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4704




*** Issue 5951 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4704


bearophile_hugs eml.cc changed:

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



Fixed here:

https://github.com/D-Programming-Language/druntime/commit/8bca49ce59dd9599085775b4dc9ed37e67241b87

https://github.com/D-Programming-Language/druntime/commit/b4d95e4db945ec443b391bf2e1746826f0acf57d

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