Detect unused variables

Jonathan M Davis jmdavisProg at gmx.com
Thu May 10 14:10:52 PDT 2012


On Thursday, May 10, 2012 22:30:14 Namespace wrote:
> After a short search I found a post which says, that currently
> and in future no warning is shown if unused variables exist. Is
> that correct?

There is not currently any such warning, and I wouldn't expect there to ever 
be one. As I understand it, Walter Bright finds them to be annoying, so they're 
unlikely to be added, just because of that. But it would also cause issues for 
some generic/generated code to have to worry about unused variables, so there 
are also technical issues why warning about them would be a problem.

The online documentation _does_ incorrectly state that unused local variables 
is an error, which caused some debate when that was brought up. There's also a 
related bug report ( http://d.puremagic.com/issues/show_bug.cgi?id=3960 ).

So, it's not 100% certain that there will never be a warning for unused 
variables, but I'd be surprised if such a warning was ever added.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list