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[])
The regression has been introduced by: https://github.com/D-Programming-Language/dmd/pull/4464
https://github.com/D-Programming-Language/dmd/pull/4971
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
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
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.