[Issue 7395] New: Need error on declaring a variable after `if` and`synchronized` without {}
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 29 04:13:20 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7395
Summary: Need error on declaring a variable after `if`
and`synchronized` without {}
Product: D
Version: D1 & D2
Platform: All
OS/Version: All
Status: NEW
Keywords: diagnostic
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: verylonglogin.reg at gmail.com
--- Comment #0 from Denis <verylonglogin.reg at gmail.com> 2012-01-29 15:13:17 MSK ---
---
synchronized int i; // should be definitely an error
if(true) int i; // IMHO, should be an error
if(true) l: f(); // should be probably an error
---
Consider the following D code copied from C:
---
volatile int* p; // volatile statements deprecated; use synchronized statements
instead
---
A one is forced to change `volatile` -> `synchronized` after brief look at the
error and, if he will be unhappy enough, his program will compile.
Therefore a case with `if` looks lass common but still signalize about an
error.
An it is an error in C# (like a variant with label probably because of possible
`l: int i;` case): `error CS1023: Embedded statement cannot be a declaration or
labeled statement`.
Also look at Issue 2197.
--
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