javascript script warning in abDragDrop.js

VERIFIED FIXED

Status

--
minor
VERIFIED FIXED
16 years ago
14 years ago

People

(Reporter: stephend, Assigned: schapel)

Tracking

Trunk
x86
Windows 2000

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

16 years ago
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.
(Reporter)

Updated

16 years ago
Attachment #123316 - Flags: superreview?(sspitzer)
Attachment #123316 - Flags: review?(cavin)

Comment 2

16 years ago
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-
(Assignee)

Comment 6

15 years ago
Created attachment 125624 [details] [diff] [review]
recommended patch
(Assignee)

Updated

15 years ago
Attachment #125624 - Flags: review?(sspitzer)
(Assignee)

Updated

15 years ago
Attachment #125624 - Flags: superreview?(bzbarsky)
Attachment #125624 - Flags: superreview?(bzbarsky) → superreview+
(Assignee)

Updated

15 years ago
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+
(Assignee)

Comment 9

15 years ago
timeless checked this in.
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
(Reporter)

Comment 10

14 years ago
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.