Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
October 13, 2015 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 John Colvin <john.loughran.colvin@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |john.loughran.colvin@gmail. | |com --- Comment #4 from John Colvin <john.loughran.colvin@gmail.com> --- If th(In reply to Kenji Hara from comment #1) > The change is introduced by fixing bug 9050 (5fb19ce). But it's not a > regression. > > With old versions, the OP code had been *wrongly* accepted. So it was accepts-invalid bug. The error message is intended and reject invalid code expectedly. > > === > > To be things more clear, I'd explain a current limitation. > > Currently, D/dmd does not support nested context inference for indirectly instantiated template lambdas. It is known limitation (at least to me). For example following case does not work: > > struct Lambda(alias fun) > { > auto opCall(A...)(A args) { return fun(args); } // Line 3 > } > void main() > { > int n = 10; > Lambda!(x => x + n) f; > assert(f(1) == 11); // Line 9 > } > > Output: > test.d(3): Error: function test.main.Lambda!((x) => x + > n).Lambda.opCall!(int).opCall cannot access frame of function D main > test.d(9): Error: template instance test.main.Lambda!((x) => x + > n).Lambda.opCall!(int) error instantiating > > The template lambda x => x + n has context access (reading local variable n > declared in main). > But, until Lambda.opCall is instantiated, the 'nestedness' is unknown. > Therefore compiler won't supply hidden member for Lambda!(x => x + n) struct > object. > Finally, f(1) will call `fun` from instantiated opCall method, but it does > not know the context pointer of main function, so fun(args) makes the error > "cannot access frame of function D main". > > Because of the limitation, currently it is impossible to create polymorpthic lambda by using existing language primitives. > > === > > The OP code hits the limitation. By the dmd bug, it had been wrongly accepted. But currently it is fixed and expectedly rejected. > > So, I'll change this issue to 'enhancement'. Is this limitation likely to be ever lifted? I come across it quite frequently and it's often pretty hard/ugly to work around. -- |
March 12, 2016 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> --- https://github.com/D-Programming-Language/dmd/pull/5518 -- |
March 24, 2016 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> --- *** Issue 12318 has been marked as a duplicate of this issue. *** -- |
March 26, 2016 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 --- Comment #7 from github-bugzilla@puremagic.com --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/703ebeb748134cbdcc65c1032f79a93692173789 fix Issue 11886 - "cannot access frame" error on lambda in lambda A function local struct (including instantiated ones) will be nested when it contains one or more template declarations. https://github.com/D-Programming-Language/dmd/commit/0624da5eb7568cfded19b1935e33af7c9d29844a Merge pull request #5518 from 9rnsr/fix11886 Issue 11886 - "cannot access frame" error on lambda in lambda -- |
March 26, 2016 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 github-bugzilla@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED -- |
July 03, 2017 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tobias@pankrath.net --- Comment #8 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> --- *** Issue 12204 has been marked as a duplicate of this issue. *** -- |
September 19, 2017 [Issue 11886] "cannot access frame" error on lambda in lambda | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11886 Alex <sascha.orlov@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sascha.orlov@gmail.com --- Comment #9 from Alex <sascha.orlov@gmail.com> --- Is #17841 a related issue? -- |
Copyright © 1999-2021 by the D Language Foundation