www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8649] New: Not accepted "const ref Type" in foreach

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

           Summary: Not accepted "const ref Type" in foreach
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



void foo(ref const int x) {} // OK
void bar(const ref int x) {} // OK
void main() {
    foreach (ref const int x; [1, 2, 3]) {} // OK
    foreach (const ref int x; [1, 2, 3]) {} // error
}


DMD 2.061alpha gives:

test.d(5): Error: basic type expected, not ref
test.d(5): Error: no identifier for declarator const(int)
test.d(5): Error: found 'ref' when expecting ';'
test.d(5): Error: found 'x' when expecting '.' following int
test.d(5): Error: found ';' when expecting identifier following 'int.'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 13 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8649




This is a dup of issue 4090.

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





 This is a dup of issue 4090.
At first sight it doesn't look like the same issue, because here I am listing all the types and modifiers. "const ref int" is refused, while "ref const int" is accepted. In both cases no type inferencing is required. While in issue 4090 I put "const ref" so some type inferencing was required. In the end if you think it's the same issue feel free to close this issue as a duplicated. Thank you. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 13 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8649


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE





 This is a dup of issue 4090.
At first sight it doesn't look like the same issue, because here I am listing all the types and modifiers. "const ref int" is refused, while "ref const int" is accepted. In both cases no type inferencing is required. While in issue 4090 I put "const ref" so some type inferencing was required. In the end if you think it's the same issue feel free to close this issue as a duplicated. Thank you.
As I explained in the issue, it's current grammar limitation, and it doesn't matter whether a type inference is required. So I'll change this to 'resolved duplicated'. *** This issue has been marked as a duplicate of issue 4090 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2012