Thread overview
[Issue 7650] New: Bad lambda inference in associative array literal
Mar 05, 2012
Kenji Hara
Mar 05, 2012
Kenji Hara
Mar 05, 2012
Walter Bright
March 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7650

           Summary: Bad lambda inference in associative array literal
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-05 06:43:49 PST ---
void main()
{
    int[int function(int)] aa1 = [x=>x:1, x=>x*2:2];
    foreach (k, v; aa1) {
        if (v == 1) assert(k(10) == 10);
        if (v == 2) assert(k(10) == 20);
    }

    int function(int)[int] aa2 = [1:x=>x, 2:x=>x*2];
    assert(aa2[1](10) == 10);
    assert(aa2[2](10) == 20);

    int n = 10;
    int[int delegate(int)] aa3 = [x=>n+x:1, x=>n+x*2:2];
    foreach (k, v; aa3) {
        if (v == 1) assert(k(10) == 20);
        if (v == 2) assert(k(10) == 30);
    }

    int delegate(int)[int] aa4 = [1:x=>n+x, 2:x=>n+x*2];
    assert(aa4[1](10) == 20);
    assert(aa4[2](10) == 30);
}

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


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-05 06:48:23 PST ---
https://github.com/D-Programming-Language/dmd/pull/789

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



--- Comment #2 from github-bugzilla@puremagic.com 2012-03-05 11:29:18 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/cb3e5bbd8c1c2ce74f09a6cb6af962de992c4b06 fix Issue 7650 - Bad lambda inference in associative array literal

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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