Closed Bug 233274 Opened 21 years ago Closed 21 years ago

for/in loop goes through array elements in wrong order

Categories

(Rhino Graveyard :: Core, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: hannesw, Assigned: igor)

Details

Attachments

(1 file)

User-Agent: Build Identifier: When an array is built using an array literal and elements are added to the array later on (using array[x]=y or array.push(y)), looping through it with a for-in loop goes through elements in wrong order. It seems the elements added later are always processed first. Reproducible: Always Steps to Reproduce: Rhino 1.5 release 5 0000 00 00 js> var array = [1, 2, 3]; js> array.push(4); 4 js> for (var i in array) print(i); Actual Results: 3 0 1 2 Expected Results: 0 1 2 3
Reassigning to Igor (hope that's ok ;-)
Assignee: nboyd → igor
Summary: for/in loop goes through array elements in wrong order → for/in loop goes through array elements in wrong order
Since array literals in Rhino creates instances of NativeArray with the internal dense array containing literal elements, the patch changes NativeArray.getIds to return ids array with dense indexes coming first and indexes for elements added later after that.
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: