digitalmars.D.bugs - [Issue 4924] New: Suspect indentation warning
- d-bugmail puremagic.com (54/54) Sep 23 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4924
- d-bugmail puremagic.com (6/6) Sep 23 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4924
- d-bugmail puremagic.com (14/14) Jan 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4924
http://d.puremagic.com/issues/show_bug.cgi?id=4924
Summary: Suspect indentation warning
Product: D
Version: D1 & D2
Platform: All
OS/Version: All
Status: NEW
Keywords: diagnostic
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
don't determine the semantics of the program. Yet programmers are humans, they
do make mistakes, and for them indentations have meaning and importance (this
is why good programmers usually indent their code carefully). A badly indented
code doesn't just look sloppy, it may hide semantic problems.
To reduce the noise it's important to minimize false positives, so the D
compiler may issue warnings (errors are too much) only in few specific
situations where a bad indentation is a clue of a possible semantic bug, and
ignore indentations in all other situations.
A situation that may justify a warning, an unexpected positive indentation
after a single-line then/else/for/foreach/while:
if (x > 5)
a = 1;
b = 2; // suspect indentation warning
if (y > 2)
c = 3;
else
d = 4;
e = 5; // suspect indentation warning
for (int i = 0; i < 10; i++)
f++;
g++; // suspect indentation warning
foreach (j; 0 .. 10)
h++;
j++; // suspect indentation warning
while (x < 10)
x = foo(x);
y++; // suspect indentation warning
if (x > 5)
a = 1; b = 2; // no warning here?
if (x > 5)
a = 1;
b = 2; // no warning here
if (x > 5) a = 1; b = 2; // no warning here
This simple warning is able to catch some common bugs (just as requiring {}
instead of just a semicolon avoids other similar bugs).
See also bug 4357
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 23 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4924 Sorry, my mistake, I meant see also bug 4375 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 23 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4924
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |WONTFIX
12:31:49 PST ---
D is insensitive to whitespace formatting, and trying to force it into sort of
being one would be a mistake.
Enforcing indenting rules is the job of a pretty printer, not the compiler.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2011









d-bugmail puremagic.com 