Reputation: 1021
I have a simple project that does some generic array calculations and returns the result in a grid. I needed a short way to scan an array for the maximum value and tried using this:
var max = Math.max.bind( Math.max );
var vector_max = Function.apply.bind( max, null );
Now, this works great when I am not debugging. But, if I wrap a test function around any statement, like, say:
function tester() {
var r = 0;
return r;
}
..., set a breakpoint anywhere in this function, and click debug, I get an error:
"Typeerror: This operation is not allowed. (line XXX, file xxx)"
This happens even in a completely new script attached to an empty sheet. Of course, Google has no documentation on their script debugger and no references to any limitations, so, I am totally in the dark.
Any ideas?
Upvotes: 4
Views: 268
Reputation: 17792
I can also reproduce this. It indeed seems like a bug in the debugger! :)
You should report this in the Apps Script issue tracker. And in the mean time use another implementation for your vector_max
function to debug your code. For example:
function vector_max(a){ return a.reduce(function(r,v){ return r < v ? v : r; }, -Infinity); }
Upvotes: 2