Closed Bug 205709 Opened 21 years ago Closed 21 years ago

javascript script warning in abDragDrop.js

Categories

(SeaMonkey :: MailNews: Address Book & Contacts, defect)

x86
Windows 2000
defect
Not set
minor

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: stephend, Assigned: schapel)

Details

Attachments

(1 file, 1 obsolete file)

Warning: redeclaration of var i
Source File: chrome://messenger/content/addressbook/abDragDrop.js
Line: 163, Column: 15
Source Code:
      for (var i=0;i<numrows;i++) {

the local variable i is already declared in:

111       for (var i = 0; i < dragSession.numDropItems; i++) {

and since JS is function-scoped for locals declared with the var keyword, we can
just drop the declaration in line 163.  patch coming up.
Attached patch Patch (obsolete) — Splinter Review
Attachment #123316 - Flags: superreview?(sspitzer)
Attachment #123316 - Flags: review?(cavin)
Comment on attachment 123316 [details] [diff] [review]
Patch

Seems like this change will affect/alter the control var 'i' in the top level
for loop (ie, line 111) right?
But we can't be in two loops at the same time, can we?

And both times, i is initialized back to 0 in each loop.
Comment on attachment 123316 [details] [diff] [review]
Patch

until I get a clue about scope inside of iterating |for| loops...
Attachment #123316 - Flags: superreview?(sspitzer)
Attachment #123316 - Flags: review?(cavin)
Comment on attachment 123316 [details] [diff] [review]
Patch

I'd prefer that we just rename this inner, shadowed, i to j.
Attachment #123316 - Flags: superreview-
Attachment #125624 - Flags: review?(sspitzer)
Attachment #125624 - Flags: superreview?(bzbarsky)
Attachment #125624 - Flags: superreview?(bzbarsky) → superreview+
Attachment #125624 - Flags: review?(sspitzer) → review?(stephend)
Reassigning.
Assignee: stephend → stevechapel
Comment on attachment 125624 [details] [diff] [review]
recommended patch

r=stephend, assuming you've tested, as well
Attachment #125624 - Flags: review?(stephend) → review+
timeless checked this in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Verified FIXED using build 2004-09-15-12 on Windows XP, Seamonkey trunk.
Status: RESOLVED → VERIFIED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: