Issue 14973 - [REG2.068] compiler inference of contexts for nested map seems broken
Summary: [REG2.068] compiler inference of contexts for nested map seems broken
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2015-08-28 03:40 UTC by Kenji Hara
Modified: 2016-02-02 03:02 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2015-08-28 03:40:50 UTC
This is separated from issue 14962 because the root issue is not exactly same.

import std.range;
import std.algorithm;

class Foo {
    int baz() {    return 1;}
    void bar() {
        auto s = [1].map!(i => baz()); // compiles
        auto r = [1].map!(i => [1].map!(j => baz())); // error
    }
}

testfoo.d(8): Error: need 'this' for 'baz' of type 'int()'
/Users/steves/git/dmd2/osx/bin/../../src/phobos/std/algorithm/iteration.d(459):        instantiated from here: MapResult!(__lambda2, int[])
testfoo.d(8):        instantiated from here: map!(int[])
/Users/steves/git/dmd2/osx/bin/../../src/phobos/std/algorithm/iteration.d(549):        instantiated from here: __lambda2!int
/Users/steves/git/dmd2/osx/bin/../../src/phobos/std/algorithm/iteration.d(459):        instantiated from here: MapResult!(__lambda2, int[])
testfoo.d(8):        instantiated from here: map!(int[])
Comment 1 Kenji Hara 2015-08-28 03:41:46 UTC
The regression has been introduced by:
https://github.com/D-Programming-Language/dmd/pull/4464
Comment 3 github-bugzilla 2015-08-28 18:07:08 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e891688d80a398be2fc41366184cd26e8229406e
fix Issue 14973 - compiler inference of contexts for nested map seems broken

https://github.com/D-Programming-Language/dmd/commit/955eb73f73a31ef52cd3e619fc3b8b1b8bb0f19e
Merge pull request #4971 from 9rnsr/fix14973

[REG2.068] Issue 14973 - compiler inference of contexts for nested map seems broken
Comment 4 github-bugzilla 2015-08-29 08:02:25 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e891688d80a398be2fc41366184cd26e8229406e
fix Issue 14973 - compiler inference of contexts for nested map seems broken

https://github.com/D-Programming-Language/dmd/commit/955eb73f73a31ef52cd3e619fc3b8b1b8bb0f19e
Merge pull request #4971 from 9rnsr/fix14973
Comment 5 github-bugzilla 2016-02-02 03:02:15 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c80bfca2d8f43e2f9b87e79473c7f6b677db66d3
Fix issue 14973 case again

For the correct lambda context inference, serialize semantic3 order of any
template instances with lambdas.

Then, an inner lambda nested-ness will be determined always in previous of enclosing lambdas.