October 06, 2014 [Issue 13577] New: More informative error message for refused immutable foreach loop | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13577 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[]) -- |
Copyright © 1999-2021 by the D Language Foundation