www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Dangling if

So I just had a bug I thought I'd never have: dpaste.dzfl.pl/5c0ab8b8

It's pretty obvious what's going on from that code snippet. But in a
larger codebase where refactoring happens often it's easy to make a
mistake of leaving out a "dangling" if statement, which is exactly
what happened here.

It could be controversial, but maybe we should consider banning the
use of blank spaces between the beginning of a *non-blocked* if
statement and the next statement. IOW:

This is OK:
if (state) {

statement 1..
statement 2..

This is not ok:
if (state)

statement 1..
statement 2..

Sep 27 2012