digitalmars.D.bugs - [Issue 15368] New: Improve error message for "auto" keyword inside
- via Digitalmars-d-bugs (26/27) Nov 20 2015 https://issues.dlang.org/show_bug.cgi?id=15368
https://issues.dlang.org/show_bug.cgi?id=15368 Issue ID: 15368 Summary: Improve error message for "auto" keyword inside "foreach" Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ajidala gmail.com Users may attempt to do type inference in foreach statements in the following way: foreach (auto e; foo) { } However, this causes the following compilation error:Error: basic type expected, not autoThis can be fairly misleading as an inexperienced programmer may assume that type inference is not possible inside foreach statements, as the compiler says it expects a basic type (when it syntactically actually doesn't). As per http://forum.dlang.org/post/cwlvurvwdnqeourtvbvi forum.dlang.org I suggest adding a special case if the unexpected token inside a foreach statement's declaration is "auto", pointing out that "auto" is neither needed nor allowed in this context to get type inference. --
Nov 20 2015