www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13577] New: More informative error message for refused


          Issue ID: 13577
           Summary: More informative error message for refused immutable
                    foreach loop
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

This is a low-priority diagnostic enhancement request. I'd like a more
informative error message for situations like:

import std.algorithm: enumerate;
void main() {
    auto arr = [[1]];
    foreach (immutable i, const x; arr.enumerate) {}     // OK
    foreach (immutable i, immutable x; arr.enumerate) {} // Error

dmd 2.067alpha gives:

temp.d(5,5): Error: cannot infer argument types

I'd like an error message that explains that x can't be immutable. See this
other example:

void main() {
    auto arr = [[1]];
    immutable a0 = arr[0];

It gives an informative message:

test.d(3): Error: cannot implicitly convert expression (arr[0]) of type int[]
to immutable(int[])

Oct 06 2014