Dear all,

Maybe I have missed something, but Stan started to inform me about the error with “wrong” line numbers which makes very difficult to debug. I think it’s been changed in one of the latest updates, because before that it worked perfectly.

For example, I have got the following mistake:

Exception: vector[uni] indexing: accessing element out of range. index 58 out of range; expecting index to be between 1 and 57 (in ‘…/Dropbox/XXX.stan’, line 563, column 12 to column 61)

but when I look at line 563, it is a part of the internal

```
vector dLognorm(real param1, real param2, int K) {
vector[K] res;
for (k in 1:K)
res[k] = lognormal_cdf(k - 0.5 | param1, param2); // here is the Line 563
return append_row(res[1], tail(res, K-1) - head(res, K-1));
}
```

Later I use the dLognorm in my generated quantities, and I think it causes the error.

As you can see, it is more difficult to say where the error had occurred (especially, if you use dLognorm function not once).

Have someone noticed something similar?

-Andrei

Thanks for reporting. Is this from an include? We used to print out the whole stack of include locations, but I’m not 100% sure what changed. @WardBrian should know.

It is difficult to say what may be occurring without seeing the full Stan code (It seems to be quite large, if line 563 is still inside the `functions`

block?) and knowing which interface you are using

Hi all,

Thank you for your replies! After investigating for some time, I think the messages look reasonable - just at first, they seem out of place. Indeed I had a mistake in the boundaries, and I figure it out.

For example,

```
array[K, Tmax] vector[D + 1] beta; // somewhere below I violate the second dimention with t > Tmax
for (t in 1:Tmax+2)
for (w in 1:K)
beta[w, t] = dLognorm(param1_delay_ref[t] + log(K * omega[w]), param2_delay, D + 1); // (YYY)
for (t in T-H+1:T) {
vector[D+1] beta_current;
for (d in 1:D+1)
beta_current[d] = t - d + 1 > 0 ? beta[omega_idx[t - d + 1, d], t - d + 1, d] : 0; // (XXX)
beta_current /= sum(beta_current);
```

If I make a mistake in the very first line, such that the second dimension and `t-d+1`

would go above `Tmax`

, Stan would point out either on line XXX or in the internal function `dLognorm`

in YYY and in the declaration of `dLognorm`

somewhere earlier in the code.

Of course, it takes time to find the source of the error and really point on the mistake in declaring the dimensions of `beta`

.

Thank you again for your time!