[Issue 22497] Spurious dual-context error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 10 14:30:58 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22497

kinke <kinke at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net

--- Comment #1 from kinke <kinke at gmx.net> ---
AFAIK, the problem is that the alias template parameter doesn't capture the
context if bound to a nested function, unlike a delegate runtime parameter.
`canon!"abc".fun!<delegateLambda>` would need a hidden context runtime
parameter to forward to the lambda invocation:

auto canon!"abc".fun!<lambda>(void* __lambda_context, int x) {
    return <lambda>(__lambda_context, x);
}

void main() {
    int x = 42;
    canon!"abc".fun!(y => y + x)(<main_context>, 1);
}

--


More information about the Digitalmars-d-bugs mailing list