www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6638] New: Suggestions/error messages for misuses of for/foreach

http://d.puremagic.com/issues/show_bug.cgi?id=6638

           Summary: Suggestions/error messages for misuses of for/foreach
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Languages and compilers copy each other all the time. This is a low-priority
diagnostic enhancement request inspired by Rust compiler:

https://github.com/graydon/rust/wiki/Error-reporting

 Use of for where for each was meant.
 
 for (v in foo.iter()) // suggest "for each"
void main() { int[5] a; } DMD 2.055 gives: test.d(2): found '..' when expecting ';' following for condition test.d(4): found ')' when expecting ';' following for condition test.d(5): found 'foreach' when expecting ')' test.d(5): found '=' when expecting '.' following int test.d(5): found '0' when expecting identifier following 'int.' test.d(5): found ';' when expecting ')' test.d(5): found 'i' when expecting ';' following statement test.d(5): found '<' instead of statement test.d(5): found ')' when expecting ';' following statement test.d(6): basic type expected, not 0 test.d(6): no identifier for declarator int test.d(6): found '0' when expecting ';' test.d(6): expression expected, not '..' test.d(6): found '10' when expecting ')' test.d(6): found ')' instead of statement test.d(7): Declaration expected, not 'foreach' test.d(8): no identifier for declarator x test.d(8): semicolon expected, not ')' test.d(8): Declaration expected, not ')' test.d(9): no identifier for declarator x test.d(9): no identifier for declarator a In some (or all) such 7 situations the D compiler can generate specific better error messages, with a suggestion. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011