Community
Participate
Working Groups
Build ID: M20080911-1700 Steps To Reproduce: 1. Create a new JavaScript project with a single JS file. 2. Enter "var x, x;" into the file (without quotes). 3. Get "Duplicate local variable x" errors about perfectly valid JavaScript. More information: Unlike Java, JavaScript does allow a variable to be declared multiple times. The real-world use case is multiple "for (var i..." loops in a function. Replacing them with a simple "for (i..." and a separate "var i" makes the code much less readable because of the hunt-the-declaration game one would have to play then.
I would propose adding a new option to the Validator preferences(under Potential Programming Problems) to allow the users to specify how they want this situation handled. We can default this option to warning or ignore. It is valid javascript, but I could see someone unintentionally duplicating variables and they may want to be notified of that.
An option would work, too.
Created attachment 118297 [details] Adds an option to the preference page to decide how to display a duplicate local variables problem.
Checked in patch
Verified in 20081215095735