[Issue 252] New: -w and switch returns = compile errors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 14 15:04:37 PDT 2006


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

           Summary: -w and switch returns = compile errors
           Product: D
           Version: 0.162
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: jpelcis at gmail.com


char[] foo (int bar) {
        switch (bar) {
                case 1:
                        return "1";
                case 2:
                        return "2";
                default:
                        return "many";
        }
}


Compiling this gives the following incorrect error message:

C:\programs>dmd -w test.d
warning - test.d(1): function test.foo no return at end of function


Severity is minor because there are at least 3 easy workarounds:

Use if-else.
Assign to a temporary variable and return that outside of the switch.
Place a return immediately after the switch.


-- 




More information about the Digitalmars-d-bugs mailing list