The following function passes syntax check using cmdstanr, but it will not compile:

```
real beta_PDF(real x, real a, real b) {
if(a<=0 || b<=0) {
print("bad a or b");
return 0;
}
if(x<=0 || x>=1) {
if(x<0 || x>1) {
print("bad x input into beta_pdf: ", x);
}
return 0;
}
return (1 / beta(a,b)) * pow(x, a-1) * pow((1-x), b-1);
}
real[] fX_ODE(real x, array[] real y, array[] real theta, array[] real x_r, array[] int x_i ) {
real m = theta[1];
real M = theta[2];
real sO1 = theta[3];
real sO2 = theta[4];
real sD1 = theta[5];
real sD2 = theta[6];
real t = theta[7];
if(M==x) {
return { 0.0 };
}
real res = (beta_PDF((x-m)/(M-m), sO1, sO2)/(M-m)) * (1-beta_cdf((t-x)/(M-x), sD1, sD2));
return { res };
}
```

However, the following will compile:

```
[...]
real[] fX_ODE(real x, array[] real y, array[] real theta, array[] real x_r, array[] int x_i ) {
real m = theta[1];
real M = theta[2];
real sO1 = theta[3];
real sO2 = theta[4];
real sD1 = theta[5];
real sD2 = theta[6];
real t = theta[7];
if(M==x) {
real resB = 0.0;
return { resB };
}
real res = (beta_PDF((x-m)/(M-m), sO1, sO2)/(M-m)) * (1-beta_cdf((t-x)/(M-x), sD1, sD2));
return { res };
}
```

The issue seems to be in the â€śreturn { 0.0 };â€ť statement. Why doesnâ€™t the compiler recognize the correct data type here?

This isnâ€™t a big deal, but I couldnâ€™t find it documented, and it took a while to discover the hack that made the program compile.

Thanks for your thoughts.