Uninformative error message

we’re teaching Stan in Tuebingen right now, and one of our students defined a variable in generated quantities, something like:

int x;

but when using that variable called in x1 by mistake.

On running the model, (using stan()) the model immediately failed to compile, saying there was a c++ compiler error, for an “unknown reason”. Is it possible to have stan complain more specifically about the variable x1 not having been defined? I can release a minimum working example if this is not clear.

Mac I assume?

yes.

I think that has been fixed for Stan 2.17.x, at least for parser errors. However, it is apparently possible for some Macs to mishandle exceptions during sampling

Can you send a code example? I’m not sure what “called in x1 by mistake” means.

This was compile time.

I just guessed.

With this model foo.stan:

transformed data {
  real x = 5;
  real y = x1;
}

I get this (running Mac OS X)

> library(rstan)
Loading required package: ggplot2
Loading required package: StanHeaders
rstan (Version 2.16.2, packaged: 2017-07-03 09:24:58 UTC, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
> setwd("~/temp2")
> stan_model("foo.stan")
SYNTAX ERROR, MESSAGE(S) FROM PARSER:

variable "x1" does not exist.
  error in 'model890b97ca157_foo' at line 3, column 14
  -------------------------------------------------
     1: transformed data {
     2:   real x = 5;
     3:   real y = x1;
                     ^
  -------------------------------------------------

Error in stanc(file = file, model_code = model_code, model_name = model_name,  : 
  failed to parse Stan model 'foo' due to the above error.

I will try to reproduce error and post a full example. Unfortunately, the
error was on someone else’s Mac. I have never seen this error message on my
Mac.