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

           Summary: Disallow `ref` in front tuple expansion in foreach
                    over range
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Denis Shelomovskij <[email protected]> 2014-01-15 
12:46:34 MSK ---
As currently `ref` is allowed in front tuple expansion such dangerous code is
accepted and fails only in runtime:
---
import std.range;

void main()
{
    int[] arr = new int[1];
    foreach(ref a, b; zip(arr, new int[1]))
        ++a;
    assert(arr[0] == 1);
}
---

IMO such code should reject to compile as I see no general use for access to
tuple element by `ref`. Broken after such change code most likely is invalid.

Also front tuple expansion in foreach over range isn't documented. See Issue
7361.

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

Reply via email to