Skip to content

Commit d29c52e

Browse files
committed
add test
1 parent e50e477 commit d29c52e

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

R/model.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,12 @@ compile <- function(quiet = TRUE,
686686
)
687687
)
688688
if (is.na(run_log$status) || run_log$status != 0) {
689-
stop("An error occured during compilation! See the message above for more information.",
690-
call. = FALSE)
689+
err_msg <- "An error occured during compilation! See the message above for more information."
690+
if (grepl("auto-format flag to stanc", run_log$stderr)) {
691+
format_msg <- "\nTo fix deprecated or removed syntax please see ?cmdstanr::format for an example."
692+
err_msg <- paste(err_msg, format_msg)
693+
}
694+
stop(err_msg, call. = FALSE)
691695
}
692696
if (file.exists(exe)) {
693697
file.remove(exe)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters {
2+
real x[3];
3+
}
4+
model {
5+
x ~ normal(0, 1);
6+
}

tests/testthat/test-model-compile.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ test_that("compile errors are shown", {
174174
)
175175
})
176176

177+
test_that("compile suggests using format to fix old syntax", {
178+
stan_file <- testing_stan_file("old_array_syntax")
179+
expect_error(
180+
cmdstan_model(stan_file),
181+
"To fix deprecated or removed syntax please see ?cmdstanr::format for an example.",
182+
fixed = TRUE
183+
)
184+
})
185+
177186
test_that("dir arg works for cmdstan_model and $compile()", {
178187
tmp_dir <- tempdir()
179188
tmp_dir_2 <- tempdir()

0 commit comments

Comments
 (0)