# Uninformative error message

**URL:** <https://discourse.mc-stan.org/t/uninformative-error-message/1919>\
**Category:** RStan\
**Created:** [September 17, 2017, 1:55pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919 "2017-09-17T13:55:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasishth](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/vasishth/32/142_2.png) [@vasishth](https://discourse.mc-stan.org/u/vasishth)\
**Post date:** [September 17, 2017, 1:55pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/1 "2017-09-17T13:55:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [September 17, 2017, 1:57pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/2 "2017-09-17T13:57:35Z")

</div>

Mac I assume?

---

<div class="post-metadata">

**Author:** ![vasishth](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/vasishth/32/142_2.png) [@vasishth](https://discourse.mc-stan.org/u/vasishth)\
**Post date:** [September 17, 2017, 2:06pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/3 "2017-09-17T14:06:31Z")

</div>

yes.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [September 17, 2017, 2:56pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/4 "2017-09-17T14:56:28Z")

</div>

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

> [@Error in rstan\_2.16.2 after upgrading to R 3.4.1 with Clang 4.0.0](http://discourse.mc-stan.org/t/error-in-rstan-2-16-2-after-upgrading-to-r-3-4-1-with-clang-4-0-0/1893/6):
>
> Thanks. It looks as if there is a typical C++ exception being thrown due to a matrix not being numerically positive definite and that takes down the whole process, which it shouldn’t. @Bob_Carpenter do you see anything fishy?

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [September 19, 2017, 11:42pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/5 "2017-09-19T23:42:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [September 19, 2017, 11:43pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/6 "2017-09-19T23:43:24Z")

</div>

> [@bgoodri](#):
>
> it is apparently possible for some Macs to mishandle exceptions during sampling

This was compile time.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [September 19, 2017, 11:46pm UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/7 "2017-09-19T23:46:33Z")

</div>

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.

```

---

<div class="post-metadata">

**Author:** ![vasishth](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/vasishth/32/142_2.png) [@vasishth](https://discourse.mc-stan.org/u/vasishth)\
**Post date:** [September 22, 2017, 9:44am UTC](https://discourse.mc-stan.org/t/uninformative-error-message/1919/8 "2017-09-22T09:44:33Z")

</div>

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.
