Open alashworth opened 5 years ago
Issue by bob-carpenter Monday Sep 11, 2017 at 10:51 GMT Originally opened as https://github.com/stan-dev/stan/issues/2395
Right now, local variables are promoted to the return type of a function or the type of a block. But if they're data variables, this overpromotes.
We could lean lean on the data qualifiers in function declaration to help know that variables can safely be double or int.
data
double
int
For example,
real foo(real x, real y, real z) { real a = y^2 + z^2;
will declare the local variable for a using the return type of the function, which is the promotion of all three types, not just y's and z's.
a
y
z
Same situation with
model { real a = y^2 + z^2;
If y and z are data variables, then a can be declared as double.
v2.17.0
Comment by VMatthijs Thursday Dec 13, 2018 at 13:04 GMT
@seantalts , this might interest you. This information should be statically available in the decorated ast in stanc3.
Issue by bob-carpenter Monday Sep 11, 2017 at 10:51 GMT Originally opened as https://github.com/stan-dev/stan/issues/2395
Summary:
Right now, local variables are promoted to the return type of a function or the type of a block. But if they're data variables, this overpromotes.
Description:
We could lean lean on the
data
qualifiers in function declaration to help know that variables can safely bedouble
orint
.Reproducible Steps:
For example,
will declare the local variable for
a
using the return type of the function, which is the promotion of all three types, not justy
's andz
's.Same situation with
If
y
andz
are data variables, thena
can be declared asdouble
.Current Version:
v2.17.0