On Nov 23, 12:11 pm, Christophe Grand <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I noticed that the java array backing the "arguments" variable is reused
>   in Array iterative methods. For example:
>
> var f = function() { return arguments };
> var a = [1, 2].map(f);
> a[0][0] === a[1][0]
>
> returns true. (Spidermonkey returns false.)
>
> There's an easy fix: in NativeArray.iterativeMethod move
>    Object[] innerArgs = new Object[3];
> inside the for loop.
>
> (I ran into this issue while calling asynchronous functions e.g.
> msgs.forEach(process))... which ended processing n times the same data!)
>
> BTW I have a problem with destructuring assignment
> (https://bugzilla.mozilla.org/show_bug.cgi?id=404484) and another with
> __iterator__ in compiled mode
> (https://bugzilla.mozilla.org/show_bug.cgi?id=402331) which are beyond
> my current understanding of the Rhino codebase.
>
> Christophe

Thanks for finding this and suggesting the fix. I've committed the
change:

Checking in NativeArray.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/
NativeArray.java,v  <--  Na
tiveArray.java
new revision: 1.80; previous revision: 1.79
done

Too bad we have to allocate an array on each iteration!

--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to