Bug #3362
closed![Author: Michael Kay](https://www.gravatar.com/avatar/db6526d63053f09b62e52c2da8b2230a?rating=PG&size=50&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
![Assignee: Debbie Lockett](https://www.gravatar.com/avatar/9c2ec304a5bec55af709863d87d5f6b7?rating=PG&size=22&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
reverse() modifies its argument
100%
Description
After calling reverse($var), the value of $var is changed to be in reverse order.
reverse is implemented as arg[0].expand().reverse()
where arg[0]
is an iterator. The problem is that (a) if arg[0]
is a ForArray iterator, then expand()
returns the original array, and (b) the Javascript function reverse()
modifies its argument in-situ.
So the code needs to ensure that the array is copied before calling reverse()@, or perhaps to avoid the @expand()
operation and prepend each item returned by the iterator to a target array.
(Reported informally by John Lumley)
Please register to edit this issue
Also available in: Atom PDF Tracking page