www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5306] New: Disallow foreach ref on numeric interval

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5306

           Summary: Disallow foreach ref on numeric interval
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-12-01 18:24:54 PST ---
This code compiles and runs with no errors with DMD 2.050, but I think this
code is meaningless so it needs to be disallowed statically (items in the
interval are not lvalues): 


void main() {
    foreach (ref i; 0 .. 10) {
        i++;
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 01 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5306



--- Comment #1 from bearophile_hugs eml.cc 2011-06-26 02:08:07 PDT ---
See a newer proposal bug 6214

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 26 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5306


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |INVALID


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2012-01-20
12:36:27 PST ---
It is not meaningless. The following program:

import core.stdc.stdio;

void main() {
    foreach (ref i; 0 .. 10) {
        printf("i = %d\n", i);
        i++;
    }
}

works as expected:

i = 0
i = 2
i = 4
i = 6
i = 8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5306



--- Comment #3 from bearophile_hugs eml.cc 2012-01-21 19:43:09 PST ---
I don't agree much. A thread:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=155816

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