digitalmars.D - Dangling if
- Andrej Mitrovic (18/18) Sep 27 2012 So I just had a bug I thought I'd never have: dpaste.dzfl.pl/5c0ab8b8
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.. Thoughts?
Sep 27 2012