www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9564] New: Give module name too in "did you mean" error messages

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

           Summary: Give module name too in "did you mean" error messages
           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


--- Comment #0 from bearophile_hugs eml.cc 2013-02-21 19:10:22 PST ---
In the standard library of Haskell and D there is a function named "group" that
has similar use. If in both languages you write such function name wrongly,
adding a trailing "s" you get:


The D program:

import std.algorithm, std.stdio;
void main() {
    writeln(groups([1, 1, 1, 3, 3]));
}


DMD 2.063alpha gives the error:

temp.d(3): Error: undefined identifier groups, did you mean template
group(alias pred = "a == b", Range)(Range r)?



The Haskell program:

import Data.List
main = do
    print $ groups [1, 1, 1, 3, 3]


The GHC compiler V.7.6.1 gives the error:

temp.hs:3:13:
    Not in scope: `groups'
    Perhaps you meant one of these:
      `group' (imported from Data.List),
      `groupBy' (imported from Data.List)


Likewise I'd like the error message of the D compiler to give the module name
where group() comes from. This is useful:
- to understand better the offered suggestion, because it gives more context;
- It allows a coding trick useful when you're working with unfamiliar code:
Change an identifier from foo to fooX. The compiler will helpfully inform you

So a possible error message becomes: temp.d(3): Error: undefined identifier groups, did you mean template std.algorithm.group(alias pred = "a == b", Range)(Range r)? ------------------------ A second differnt but related possible enhancement for the D compiler (but for me with a lower priority) is to offer more than one suggestion when there is more than very similar identifier, like in the Haskell error message that suggests both "group" and "groupBy". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 21 2013