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

--- Comment #0 from 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:
------- You are receiving this mail because: -------

Reply via email to