Yesterday I upgraded to node.js v5.4, and now a few unit tests of math.js are failing. The reason for that is that the argument w of the function _wclear in file cs_amd.js is mutated inside the function, which is not allowed in strict mode.
https://github.com/josdejong/mathjs/blob/master/lib/function/algebra/sparse/cs_amd.js#L552-L562
var _wclear = function(mark, lemax, w, n) {
if (mark < 2 || (mark + lemax < 0)) {
for (var k = 0; k < n; k++) {
if (w[k] !== 0)
w[k] = 1;
}
mark = 2 ;
}
// at this point, w [0..n-1] < mark holds
return mark;
};
I first tried to fix this by copying w inside the function, mutate that, and return both mark and the copied w as an object. However, that didn't work as apparently all invocations of _wclear pass a number for w rather than an array.
@rjbaucells when I remove the for loop which mutates w, all unit tests still pass. However, I think the code was there for some reason. Do you know if this for loop can be safely removed, or are there other side effects that we should be aware of?
// ... this seems to work ...
var _wclear = function(mark, lemax) {
if (mark < 2 || (mark + lemax < 0)) {
mark = 2 ;
}
// at this point, w [0..n-1] < mark holds
return mark;
};
Yesterday I upgraded to node.js v5.4, and now a few unit tests of math.js are failing. The reason for that is that the argument
wof the function_wclearin filecs_amd.jsis mutated inside the function, which is not allowed in strict mode.https://github.com/josdejong/mathjs/blob/master/lib/function/algebra/sparse/cs_amd.js#L552-L562
I first tried to fix this by copying
winside the function, mutate that, and return bothmarkand the copiedwas an object. However, that didn't work as apparently all invocations of_wclearpass a number forwrather than an array.@rjbaucells when I remove the for loop which mutates
w, all unit tests still pass. However, I think the code was there for some reason. Do you know if this for loop can be safely removed, or are there other side effects that we should be aware of?