nimble
nimble copied to clipboard
difference in state of index variable for uncompiled and compiled for loops at end of loop
Looks like C++ increments the index variable after the loop iterations, so we have a subtle, small difference in compiled/uncompiled behavior. This affected the IF2 continueRun
method where our logic assumed R-like behavior (now fixed in nimbleSMC devel branch).
nf <- nimbleFunction(
run = function() {
returnType(double())
for(i in 1:5) {}
return(i)
})
cnf <- compileNimble(nf)
nf()
# [1] 5
cnf()
# [1] 6