www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4286] New: Wrong error line number and more with schwartzSort

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

           Summary: Wrong error line number and more with schwartzSort
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-06-06 07:40:55 PDT ---
This is D2 code, I don't understand this bug:


import std.typecons: tuple, Tuple;
import std.algorithm: schwartzSort;

void foo(int N)(char[] txt) {
    int[char[N]] aa;
    foreach (i; 0 .. txt.length + 1 - N) {
        char[N] key = txt[i .. i + N];
        aa[key]++;
    }

    alias Tuple!(char[N], "key", int, "value") Pair;
    Pair[] pairs;
    foreach (key, value; aa)
        pairs ~= Pair(key, value);

    schwartzSort!((p){ return tuple(p.value, p.key); })(pairs);
}

void main() {
    char[] txt = cast(char[])("this is just a test".dup);
    foo!(1)(txt);
    foo!(2)(txt);
}


DMD v2.046 prints at compile-time:

test.d(4061): Error: function test.foo!(1).foo.schwartzSort!(__dgliteral1,"a <
b",cast(SwapStrategy)0,Tuple!(char[2u],"key",int,"value")[]).schwartzSort is a
nested function and cannot be accessed from foo


This work-around seems to fix the program:
schwartzSort!((Pair p){ return tuple(p.value, p.key); })(pairs);


Also note the wrong line number, this is why I have tagged this as DMD bug
instead of Phobos problem.

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


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


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



--- Comment #1 from Don <clugdbug yahoo.com.au> 2011-12-21 23:25:10 PST ---
The wrong line number was fixed in DMD2.054.
The other issue is an instance of bug 5939, bug 6217, and various others.

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |WORKSFORME


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-10
14:10:51 PST ---
Works in 2.061+.

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