Skip to content

Commit 804267a

Browse files
committed
Fix handling of exposing functions with pre-compiled Stan model
1 parent f028607 commit 804267a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

R/model.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ compile <- function(quiet = TRUE,
519519
private$precompile_cpp_options_ <- NULL
520520
private$precompile_stanc_options_ <- NULL
521521
private$precompile_include_paths_ <- NULL
522+
self$functions$existing_exe <- TRUE
522523
self$exe_file(exe)
523524
return(invisible(self))
524525
} else {
@@ -586,6 +587,7 @@ compile <- function(quiet = TRUE,
586587
stancflags_standalone <- c("--standalone-functions", stancflags_val, stancflags_combined)
587588
self$functions$hpp_code <- get_standalone_hpp(temp_stan_file, stancflags_standalone)
588589
self$functions$external <- !is.null(user_header)
590+
self$functions$existing_exe <- FALSE
589591
if (compile_standalone) {
590592
expose_stan_functions(self$functions, !quiet)
591593
}

R/utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,10 @@ expose_stan_functions <- function(function_env, global = FALSE, verbose = FALSE)
914914
"WSL CmdStan and will not be compiled",
915915
call. = FALSE)
916916
}
917+
if (function_env$existing_exe) {
918+
stop("Exporting standalone functions is not possible with a pre-compiled Stan model!",
919+
call. = FALSE)
920+
}
917921
if (function_env$external && cmdstan_version() < "2.32") {
918922
stop("Exporting standalone functions with external C++ is not available before CmdStan 2.32",
919923
call. = FALSE)

0 commit comments

Comments
 (0)