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: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Denis Shelomovskij <[email protected]> 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: -------

Reply via email to