Thread overview
[Issue 9627] New: Not good enough error messages in some cases when using UCFS
Mar 02, 2013
Andrej Mitrovic
[Issue 9627] Not good enough error messages in some cases when using UFCS
Apr 26, 2013
Kenji Hara
March 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9627

           Summary: Not good enough error messages in some cases when
                    using UCFS
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            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-03-01 12:48:01 PST ---
I tag this as "enhancement" because I don't know if there is a way to solve this problem.


This program has a bug:


import std.stdio, std.string, std.algorithm, std.range;
void main() {
    auto data =
"Given$a$txt$file$of$many$lines,$where$fields$within$a$line$
are$delineated$by$a$single$'dollar'$character,$write$a$program
that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$
column$are$separated$by$at$least$one$space.
Further,$allow$for$each$word$in$a$column$to$be$either$left$
justified,$right$justified,$or$center$justified$within$its$column."
    .splitLines.map!q{ a.chomp("$").split("$") };

    int[int] maxWidths;
    foreach (line; data)
        foreach (i, word; line)
            maxWidths[i] = max(maxWidths.get(i, 0), word.length);

    foreach (just; [&leftJustify!string, &center!string,
                    &rightJustify!string])
        foreach (line; data)
            writefln("%-(%s %)", iota(line.length)
                     .map!(i => just(word, maxWidths[i], ' ')));
}



DMD2.063alpha gives just this error message:

temp.d(20): Error: no property 'map' for type 'Result'


Can you spot the problem?


If you add a () after the call to map:


    foreach (just; [&leftJustify!string, &center!string,
                    &rightJustify!string])
        foreach (line; data)
            writefln("%-(%s %)", iota(line.length)
                     .map!(i => just(word, maxWidths[i], ' '))());
}



It gives a large amount of error messages, but the first error message shows you clearly what's the problem:

temp.d(21): Error: undefined identifier word
...\dmd2\src\phobos\std\algorithm.d(404): Error: template instance
temp.main.__lambda2!(uint) error instantiating
...
temp.d(20): Error: template instance
std.stdio.writefln!(string,MapResult!(__lambda2, Result)) error instantiating




Lately I have started to omit the () in UCFS (according to this: http://article.gmane.org/gmane.comp.lang.d.phobos/7222 ) and I am seeing several similar situations with insufficient error messages, like that.

Is it possible for DMD to improve its error messages in similar situations?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9627


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-02 08:01:50 PST ---
Root causes:

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9627


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-04-26 04:18:14 PDT ---
This issue is solved in 2.063.

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