Closed simbo1905 closed 5 years ago
Note that your for
loop (for ( i = 0; i < secret.length; i++ ){
) is using a global variable i
. This is not a good idea. Some other loops in your code are using the same global variable as well (namely degree
function in GF256.js
). Loops of this kind do not work when one is invoked from another. In other words, i
is decreased by the mentioned degree
function. So, the infinite loop is not a bug of GraalVM JavaScript engine. I suggest you to use function or block scope variables in your loops, i.e., use for (var i=0; ...
or for (let i=0; ...
instead of for (i=0; ...
.
thanks! i have added "use strict" to the files which to stop the code from compiling while accidentally using undeclared globals.
I am running:
I have a unit test calling a module exported method here where the method has a pretty simple loop:
The logic should be looping over the array
secret
but I removed passingi
into the method call as it appears to get corrupted. The method call toGF256.generate
resetsi
to 0. So the unit test loops forever until you ctrl+c it. You can see this behaviour by checking out the branch then at the top level run:The first 15 lines are something like:
I cannot see how
i
is getting assigned back to1
in this code. I am thinking it might be a bug in graaljs