From 5887e71567fd60815afe2acfdda616246f80da32 Mon Sep 17 00:00:00 2001 From: Christopher Paciorek Date: Sat, 9 May 2026 10:00:58 -0700 Subject: [PATCH] Fix issue 162 by robustifying `nFunction` to handle 0-length `name` input. --- nCompiler/R/NF.R | 2 +- nCompiler/tests/testthat/nimble_tests/test-compileNimble.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nCompiler/R/NF.R b/nCompiler/R/NF.R index c9d699d1..d48c9809 100644 --- a/nCompiler/R/NF.R +++ b/nCompiler/R/NF.R @@ -129,7 +129,7 @@ nFunction <- function(fun, # ADfun: should become AD_nFun ### - if(missing(name)) + if(missing(name) || !length(name)) # Check for empty `name` per issue 162. name <- nFunctionLabelMaker() ## Create internals that will be used for compilation. internals <- NF_InternalsClass$new(fun, diff --git a/nCompiler/tests/testthat/nimble_tests/test-compileNimble.R b/nCompiler/tests/testthat/nimble_tests/test-compileNimble.R index b90c4cd1..13cf1ccc 100644 --- a/nCompiler/tests/testthat/nimble_tests/test-compileNimble.R +++ b/nCompiler/tests/testthat/nimble_tests/test-compileNimble.R @@ -24,7 +24,7 @@ test_that("compileNimble bridge works for one nimbleFunction object", { run = function() {return(x[1]); returnType(double())} ) nf1 <- nf() - Cnf1 <- compileNimble(nf1) + Cnf1 <- `:::`("nCompiler", "compileNimble")(nf1) expect_identical(Cnf1$x, 1:2) }) ## NEXT STEPS: