diff --git a/packages/nimble/R/BUGS_modelDef.R b/packages/nimble/R/BUGS_modelDef.R index 8aa0d0aed..78ece52b2 100644 --- a/packages/nimble/R/BUGS_modelDef.R +++ b/packages/nimble/R/BUGS_modelDef.R @@ -1540,6 +1540,13 @@ makeVertexNamesFromIndexArray2 <- function(indArr, minInd = 1, varName) { ## In the second, elements give the column index, e.g. [1 2 3; 1 2 3; 1 2 3] ## etc. arrayWithIndices <- vector('list', length = nDim) + if(is.null(dims)) + stop("Something is inconsistent in the use of `", varName, "` in the model.\n", + "Check for conflicting declarations.\n", + "If your model has macros or if-then-else blocks\n", + "you can inspect the processed model code by calling\n", + "`nimbleOptions(stop_after_processing_model_code = TRUE)`\n", + "before calling nimbleModel.\n", call. = FALSE) arrayWithIndices[[1]] <- array( rep(1:dims[1], prod(dims[-1])), dims) ## We could reduce memory footprint by doing all steps on each dimension before building arrayWithIndices for new dimension if(nDim > 1) { @@ -2484,8 +2491,8 @@ modelDefClass$methods(genExpandedNodeAndParentNames3 = function(debug = FALSE) { stop(paste0("Something is inconsistent in the model.\n", "Check for conflicting declarations.\n", "If your model has macros or if-then-else blocks\n", - "you can inspect the processed model code by doing\n", - "nimbleOptions(stop_after_processing_model_code = TRUE)\n", + "you can inspect the processed model code by calling\n", + "`nimbleOptions(stop_after_processing_model_code = TRUE)`\n", "before calling nimbleModel.\n" ), call. = FALSE)