nimble icon indicating copy to clipboard operation
nimble copied to clipboard

difference in state of index variable for uncompiled and compiled for loops at end of loop

Open paciorek opened this issue 3 years ago • 0 comments

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

paciorek avatar Dec 04 '21 21:12 paciorek