[Issue 11936] Allow non-`ref` parameters in `foreach` over range `delegate`/`opApply`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 6 12:41:16 UTC 2023


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

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #1 from Nick Treleaven <nick at geany.org> ---
Still fails:

    foreach (a; dg1) {}

foreachdelegate.d(6): Error: delegate `dg1(int delegate(int))` is not callable
using argument types `(int delegate(ref int __applyArg0) pure nothrow @nogc
@safe)`
foreachdelegate.d(6):        cannot pass argument `__foreachbody3` of type `int
delegate(ref int __applyArg0) pure nothrow @nogc @safe` to parameter `int
delegate(int)`

However, this works:

    int f(int delegate(int));
    foreach (a; &f) {}

--


More information about the Digitalmars-d-bugs mailing list