[Issue 10685] New: Immutable interval foreach to propagate index value range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 20 13:56:55 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10685

           Summary: Immutable interval foreach to propagate index value
                    range
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-07-20 13:56:55 PDT ---
Foreach on a defined interval with an immutable index is a very common
operation:


void main() {
    foreach (immutable i; 0 .. 10)
        char c = 'x' + i;
}


DMD 2.064alpha gives:

test.d(3): Error: cannot implicitly convert expression (120 + i) of type int to
char


I suggest to give (propagate) the immutable variable 'i' the range [0, 10] so
the assignment to c requires no cast.

Se also Issue 10018 , Issue 10615 , Issue 10594

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


More information about the Digitalmars-d-bugs mailing list