Difficulty compiling nimbleFunctions that depend on other nimbleFunctions in package structure.

27 views
Skip to first unread message

Scott Brown

unread,
Oct 26, 2023, 3:14:36 PM10/26/23
to nimble-users
Encountering a problem with compiling nimbleFunctions that reference other nimbleFunctions in my package.

I've reduced this to a relatively minimal example:

nimNothing <- nimbleFunction(
  run = function(){
    returnType(double(0))
    return(0)
  })

#' @export
nestedNim <- nimbleFunction(
  run = function(){
    returnType(double(0))
    return(nimNothing())
  }
)


When I attempt to `compileNimble` the `nestedNim` nimbleFunction, specifically as part of an .Rmd vignette, I get errors.  When I load them via `devtools::load_all` it works fine.  To reproduce: put these two functions in an R file in a new package, create a vignette that compiles the `nestedNim` function, and call `devtools::build_rmd(...)` to build your vignette.  The specific error that I am getting with this is:

Error in if (typeEnv$return$type == "nimbleList" || code$args[[1]]$type == : missing value where TRUE/FALSE needed

But I suspect that this is something of a red herring, as I was getting an entirely different error before reducing this to a minimal example.  If you `devtools::load_all()` and then just "Run" the .Rmd file in RStudio, everything works.  Attached is a package with the described setup.
examplePackage.zip

Scott Brown

unread,
Oct 26, 2023, 3:15:53 PM10/26/23
to nimble-users
If I #' @export the `nimNothing` function, then the .Rmd file compiles.  This is a satisfactory workaround for now, but it will become unfortunate as my package grows.

Chris Paciorek

unread,
Nov 1, 2023, 2:46:25 PM11/1/23
to Scott Brown, nimble-users
Hi Scott, I've reproduced the problem by creating a minimal package, building and installing it and then trying `compileNimble(nestedNim)`.  If I don't export `nimNothing` then I get the error you showed:

```
Error in if (typeEnv$return$type == "nimbleList" || code$args[[1]]$type == : missing value where TRUE/FALSE needed
```

I'll put this on our list of issues to investigate.

--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/ec05a1c7-6ae7-4ab3-b38f-fde7c755bc4fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages