[Issue 9749] New: typeof(return) is sometimes disallowed for inner functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 18 11:11:27 PDT 2013


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

           Summary: typeof(return) is sometimes disallowed for inner
                    functions
           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 2013-03-18 11:11:25 PDT ---
This is borderline between enhancement request and bug report.

This is sometimes useful when you use nested functions:


int main() {
    typeof(return) foo(typeof(return) y) {
        return y * y;
    }
    return foo(1) + foo(3);
}



DMD 2.063alpha gives:

temp.d(2): Error: typeof(return) must be inside function
temp.d(5): Error: function temp.main.foo (_error_) is not callable using
argument types (int)
temp.d(5): Error: function temp.main.foo (_error_) is not callable using
argument types (int)



Note that this code gives no errors, so all errors come from "typeof(return)
y":

int main() {
    typeof(return) foo(int y) {
        return y * y;
    }
    return foo(1) + foo(3);
}

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