[Issue 5697] New: Instantiation from typetuple of templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 4 09:53:47 PST 2011


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

           Summary: Instantiation from typetuple of templates
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-03-04 09:50:53 PST ---
This D2 code compiles and runs with no errors (DMD 2.052):


template TypeTuple(TList...) {
    alias TList TypeTuple;
}
int foo(alias bar)() {
    return bar();
}
int spam() {
    return 1;
}
void main() {
    alias TypeTuple!(foo, foo) templates;
    alias templates[0] templates0; // OK
    assert(templates0!spam() == 1); // OK
}




But if I remove the alias, to merge the last two lines:

template TypeTuple(TList...) {
    alias TList TypeTuple;
}
int foo(alias bar)() {
    return bar();
}
int spam() {
    return 1;
}
void main() {
    alias TypeTuple!(foo, foo) templates;
    assert(templates[0]!spam() == 1); // line 12, error
}



It doesn't compile, with the errors:

test.d(12): found '!' when expecting ')'
test.d(12): found 'spam' when expecting ';' following statement
test.d(12): expression expected, not ')'


Some alternative ways to write this line don't seem to work:
templates[0]!spam()

-- 
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