[Issue 5073] New: wrong file name in error message for "voids have no value" inside alias templates (affects std.algorithm.map)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 18 17:29:22 PDT 2010


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

           Summary: wrong file name in error message for "voids have no
                    value" inside alias templates (affects
                    std.algorithm.map)
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: sandford at jhu.edu


--- Comment #0 from Rob Jacques <sandford at jhu.edu> 2010-10-18 17:28:42 PDT ---
There seems to be an issue with the reported filename for alias templates that
create a variable of type void. Here is a test case:

using DMD 2.049:

import std.algorithm;
void main(string[] args) {
    auto foobar  = map!( (int i){} )([0]); // using a named delegate also
errors
}

results in the error message

hello.d, Line 119
Error: variable hello.main.Map!(__dgliteral1,int[]).Map._cache voids have no
value

Line 119 of std.algorithm (part of the Map struct):
Unqual!ElementType _cache;

This may be related to issue 2180.

Here is a reduced test case that gives a slightly better set of error messages
than the std.algorithm example:

hello.d:
import std.stdio: writeln;
import goodbye;

void main(string[] args) {
    auto foobar  = map!( (int i){} )(5);
    return;
}

goodbye.d:
module goodbye;







// line 9
template map(fun...)            //
{
    auto map(Range)(Range r)
    {
        return Map!(fun)(r);    // line 14, must instantiate with fun or r not
Range
    }
}

struct Map(alias fun) {         // Must be an alias template
    void _cache;                // line 19
}


Error messages produced:

hello.d Line 19
Error: variable hello.main.Map!(delegate void(int i)
hello.d Line 14
Error: template instance hello.main.Map!(delegate void(int i)
hello.d Line 5
instantiated from here: map!(int)

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


More information about the Digitalmars-d-bugs mailing list