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

           Summary: No label and variable with the same name error
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-09-20 18:00:10 PDT ---
This compiles with no errors, but maybe it's better to refuse (and show an
error) when a label has the same name of a variable:


enum int FOO = 1;
int main() {
    goto FOO;
    FOO: return FOO;
}


That helps keep code tidy, and also helps to avoid probably wrong code like
(note the missing 'case'):

enum int CONST1 = 1;
enum int CONST2 = 2;
void main() {
    int x = 1;
    switch (x) {
        case CONST1:
            break;
        CONST2:
            break;
        default:
            break;
    }
}


Something similar toi the second situation is present among the Semantic Errors
of Java code in the Google Web Toolkit too:

http://code.google.com/intl/en-EN/webtoolkit/tools/codepro/doc/features/audit/audit_rules_com.instantiations.assist.eclipse.auditGroup.possibleErrors.html#com.instantiations.assist.eclipse.audit.nonCaseLabelInSwitch

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

Reply via email to