digitalmars.D.bugs - [Issue 4902] New: No label and variable with the same name error
- d-bugmail puremagic.com (41/41) Sep 20 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4902
- d-bugmail puremagic.com (7/7) Sep 20 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4902
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: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc 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: -------
Sep 20 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4902 So far in my code I have never had a bug caused by this, so I consider this low-priority. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 20 2010