www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11444] New: Better error messages for Phobos ranges used without bang !

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11444

           Summary: Better error messages for Phobos ranges used without
                    bang !
           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



This is wrong code:


import std.stdio, std.algorithm;
void main() {
    "123".map(d => d - '0').writeln;
}


dmd 2.064beta gives the error messages:

test.d(3): Error: template std.algorithm.map does not match any function
template declaration. Candidates are:
...\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(398):       
std.algorithm.map(fun...) if (fun.length >= 1)
test.d(3): Error: template std.algorithm.map(fun...) if (fun.length >= 1)
cannot deduce template function from argument types !()(string, void)


The mistake is in the map, it should be "map!(...)". Range-based code that uses
map, filter and other similar functions is becoming common, so I suggest to add
some euristics to the D front-end to generate better error messages for common
Phobos templates that are used without the "!", something like:

test.d(3): Error: template std.algorithm.map does not match any function
template. Did you miss a "!"?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 05 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11444


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |DUPLICATE



13:21:53 PST ---
*** This issue has been marked as a duplicate of issue 9179 ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 05 2013