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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 16 00:05:22 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11936

           Summary: Allow non-`ref` parameters in `foreach` over range
                    `delegate`/`opApply`
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2014-01-16 12:05:21 MSK ---
Test code:
---
void main()
{
    int delegate(int delegate(int)) dg1; // currently unforeachable
    int delegate(int delegate(ref int)) dg2;

    static assert( __traits(compiles, { foreach(    a; dg1) { } })); // fails
    static assert(!__traits(compiles, { foreach(ref a; dg1) { } }));
    static assert( __traits(compiles, { foreach(ref a; dg2) { } }));
}
---

As some parameters may represent e.g. temporary values it's useful to show it
disallowing `ref` on them.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list