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

           Summary: Type literal of pure function pointer inside function
                    signature
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-07-25 07:47:43 PDT ---
D2 code, foo4() shows that you can't define a pure function pointer in a
function signature:


pure int sqr(int x) {
    return x * x;
}
pure int foo1(TF)(TF func, int x) { // OK
    return func(x);
}
pure int foo2(typeof(&sqr) func, int x) { // OK
    return func(x);
}
alias pure int function(int) FN;
pure foo3(FN func, int x) { // OK, from Simen kjaeraas
    return func(x);
}
pure int foo4(pure int function(int) func, int x) { // line 14, ERR
    return func(x);
}
void main() {
    assert(foo1(&sqr, 5) == 25);
    assert(foo2(&sqr, 5) == 25);
    assert(foo3(&sqr, 5) == 25);
    assert(foo4(&sqr, 5) == 25);
}


DMD 2.047 prints:
test.d(14): basic type expected, not pure
test.d(14): found 'pure' when expecting ')'
test.d(14): semicolon expected following function declaration
test.d(14): no identifier for declarator int function(int)
test.d(14): semicolon expected, not 'int'
test.d(14): semicolon expected, not ')'
test.d(14): Declaration expected, not ')'
test.d(16): unrecognized declaration


Also, it generates too many error messages.

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

Reply via email to