Jump to page: 1 2
Thread overview
[Issue 4090] New: foreach(const ref x; a) error message
[Issue 4090] No foreach type inference with const, ref etc modifiers
Sep 07, 2011
yebblies
Sep 07, 2011
yebblies
Jul 02, 2012
Kenji Hara
Sep 16, 2012
Kenji Hara
Oct 28, 2012
yebblies
Oct 28, 2012
yebblies
Nov 03, 2012
Kenji Hara
Nov 06, 2012
Kenji Hara
Nov 10, 2012
Kenji Hara
April 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4090

           Summary: foreach(const ref x; a) error message
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-04-14 07:44:09 PDT ---
This is a D2 program:

void main() {
    double[10] arr;
    double tot = 0;
    foreach (const ref x; arr)
        tot += x;
}


dmd 2.043 prints:

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


Those error messages are too many, and they don't describe what the problem is.

Replacing the foreach line with the following line there are no compile errors:
foreach (ref const(double) x; arr)


Also note this program compiles with no errors:

void foo(const ref int x) {}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #1 from yebblies <yebblies@gmail.com> 2011-09-07 18:14:50 EST ---
*** Issue 6616 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #2 from yebblies <yebblies@gmail.com> 2011-09-07 18:15:11 EST ---
*** Issue 5255 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec
           Platform|x86                         |All
         OS/Version|Windows                     |All
           Severity|normal                      |enhancement


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-07-01 18:46:53 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1033

This is not supported by the current spec, so it is an enhancement..

http://dlang.org/statement#ForeachStatement
> ForeachStatement:
>  Foreach (ForeachTypeList ; Aggregate) NoScopeNonEmptyStatement
> 
> Foreach:
>  foreach
>  foreach_reverse
> 
> ForeachTypeList:
>  ForeachType
>  ForeachType , ForeachTypeList
> 
> ForeachType:
>   ref(opt) BasicType Declarator
>   ref(opt) Identifier

ForeachType can have only 'ref' as a storage class.
Others, 'const', 'immutable', 'shared', and 'inout' are disallowed by the
grammar.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-09-16 04:53:49 PDT ---
*** Issue 8649 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #5 from github-bugzilla@puremagic.com 2012-10-28 03:45:55 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/dda2c5cd02f2b60bb58c4c56c17727fe31c2ea45 fix Issue 4090 - No foreach type inference with const, ref etc modifiers

https://github.com/D-Programming-Language/dmd/commit/c6f32af2ccbc5a27d0174cc84121ba90eba6a6e2 Merge pull request #1033 from 9rnsr/fix4090

Issue 4090 - No foreach type inference with const, ref etc modifiers

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
         AssignedTo|nobody@puremagic.com        |k.hara.pg@gmail.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #6 from bearophile_hugs@eml.cc 2012-10-28 04:49:53 PDT ---
But this program compiles with no errors, do you want me to reopen this issue?


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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #7 from yebblies <yebblies@gmail.com> 2012-10-28 22:58:56 EST ---
Urrgh, it seems it isn't fixed for foreach range statements.

void main() {
    foreach (immutable i; 0..10)
    {
        pragma(msg, typeof(i));
        ++i;
    }
}

Prints: int

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2012-11-02 20:26:26 PDT ---
Posted an additional pull request: https://github.com/D-Programming-Language/dmd/pull/1249

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2