Bug 10877 – Possible regression: Cannot access frame of function in opCall

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-23T16:18:50Z
Last change time
2024-12-13T18:10:49Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#18657 →

Comments

Comment #0 by andrej.mitrovich — 2013-08-23T16:18:50Z
I've had this test-case in my minilib library for quite some time. It used to work in git-head versions, but not anymore, and it seems I can't get any release versions to run it (it's possible I ever tested it with git-head versions). Some git-head commits must have worked at some point but the following is now failing: ----- module test; import std.typetuple; /** Associate default values to a function in reverse. */ template CurryDefVal(alias Call, DefVals...) { // can't add constraints due to compiler bugs static if (is(typeof( CurryDefValImpl1!(Call, DefVals) ))) { alias CurryDefValImpl1!(Call, DefVals) CurryDefVal; } else // can't add check due to compiler bugs { alias CurryDefValImpl2!(Call, DefVals) CurryDefVal; } } /// void test() { static void foo(int x, float y, string z) { } alias CurryDefVal!(foo, "a", 1.0, 1) fooDef3; alias CurryDefVal!(foo, "a", 1.0) fooDef2; alias CurryDefVal!(foo, "a") fooDef1; alias CurryDefVal!(foo) fooDef0; alias CurryDefVal!(fooDef1, 2.0, 3) fooDef3_clone; fooDef0(1, 1.0, "a"); fooDef1(1, 1.0); fooDef2(1); fooDef3(); fooDef3_clone(); // demonstrates alias of scoped function static void testMe(ref int y) { if (y == 10) return; // failing all, used to work alias CurryDefVal!(testMe, y) recurse; y = 10; recurse(); } int x; testMe(x); } /* helper */ template CurryDefValImpl1(alias Call, DefVals...) if (isCallable!Call && DefVals.length <= ParameterTypeTuple!Call.length) { auto CurryDefValImpl1(T...)(T args) { return Call(args, Reverse!DefVals); } } /* helper */ struct CurryDefValImpl2(alias Call, DefVals...) { static auto opCall(T...)(T args) { return Call(args, Reverse!DefVals); } } void main() { } ----- Errors: test.d(49): Error: function test.test.testMe.CurryDefValImpl2!(testMe, y).CurryDefValImpl2.opCall!().opCall cannot access frame of function test.test.testMe test.d(74): Error: function test.test.testMe.CurryDefValImpl2!(testMe, y).CurryDefValImpl2.opCall!().opCall cannot access frame of function test.test.testMe test.d(52): Error: template instance test.test.testMe.CurryDefValImpl2!(testMe, y).CurryDefValImpl2.opCall!() error instantiating I've first introduced this as a similar function in Issue 5829. Once this frame access issue is resolved (if it can be - bit it used to work), we could introduce it into Phobos if it's useful to have after cleaning it up. And yes, the name should be "partial function application" or something like that rather than curry.
Comment #1 by andrej.mitrovich — 2013-08-23T16:21:10Z
(In reply to comment #0) > // failing all, used to work > alias CurryDefVal!(testMe, y) recurse; failing *call*
Comment #2 by robert.schadek — 2024-12-13T18:10:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18657 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB