Bug 14833 – [REG2.065] Nested delegates problem

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-26T15:17:00Z
Last change time
2015-09-01T09:50:59Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2015-07-26T15:17:07Z
void main() { import std.algorithm: map; import std.range: iota; import std.typecons: tuple; auto r1 = 100.iota.map!(a3 => iota(1, a3).map!(a2 => iota(1, a3).map!(a1 => tuple(a1, a2, a3)))); // OK auto r2 = 100.iota.map!(a3 => iota(1, a3).map!(a2 => iota(1, a2).map!(a1 => tuple(a1, a2, a3)))); // Error } dmd v2.068.0-b1 gives: test.d(6,95): Error: delegate test.main.__lambda2!int.__lambda2.__lambda2!int.__lambda2.__lambda2 cannot access frame of function test.main.__lambda2 ...\dmd2\src\phobos\std\algorithm\iteration.d(459,16): instantiated from here: MapResult!(__lambda2, Result) test.d(6,69): instantiated from here: map!(Result) ...\dmd2\src\phobos\std\algorithm\iteration.d(549,19): instantiated from here: __lambda2!int ...\dmd2\src\phobos\std\algorithm\iteration.d(459,16): ... (3 instantiations, -v to show) ... ...\dmd2\src\phobos\std\algorithm\iteration.d(459,16): instantiated from here: MapResult!(__lambda2, Result) test.d(6,23): instantiated from here: map!(Result)
Comment #1 by dlang-bugzilla — 2015-09-01T06:04:35Z
This seems to be a regression. Introduced in https://github.com/D-Programming-Language/dmd/pull/2851
Comment #2 by k.hara.pg — 2015-09-01T09:50:59Z
(In reply to Vladimir Panteleev from comment #1) > This seems to be a regression. > > Introduced in https://github.com/D-Programming-Language/dmd/pull/2851 The root issue was incomplete compiler implementation for context inference, which is same with the root of issue 14973, and it has been properly fixed in 2.068.1-b2. --- OT: Why this issue and issue 14973 had introduced in different versions? The root issue was hidden until 2.065, by other bug in template instantiation order. The instantiation bug had partially fixed by PR 2851 in 2.065, and then completely fixed in 2.068.0 by PR 4464. By the partial fix in 2.065, the case code in this issue had been changed to fail to compile. And then, by the complete fix in 2.068.0, the case in issue 14973 had been changed to fail to compile.