digitalmars.D.bugs - [Issue 19241] New: Broken value of auto ref argument for closure
- d-bugmail puremagic.com (45/45) Sep 11 2018 https://issues.dlang.org/show_bug.cgi?id=19241
https://issues.dlang.org/show_bug.cgi?id=19241 Issue ID: 19241 Summary: Broken value of auto ref argument for closure Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: zan77137 nifty.com This code doesn't work: ------------------- auto ref run(F, Args...)(F dg, auto ref Args args) { return dg(args); } auto makeClosure(alias func, Args...)(auto ref Args args) { auto fptr = args[0].funcptr; return { // !!!!! Assertion failure !!!!! assert(args[0].funcptr is fptr); return func(args); }; } auto test(F, Args...)(F dg, auto ref Args args) { return makeClosure!run(dg, args); } void main() { auto t = test( delegate ()=> 10 ); assert(t() == 10); } ------------------- dmd -debug -g -run main.d ------------------- core.exception.AssertError main.d(9): Assertion failure ---------------- 0x004029B3 in _d_assertp at ...\src\core\exception.d(436) 0x0040225B in _Dmain at main.d(20) --
Sep 11 2018