After #1305, this will read in a value for a even though one isn't expected, causing the stan::io::serializer to run out of room when trying to write the value for b, yielding an error like
Unrecoverable error evaluating the log probability at the initial value.
Exception: In serializer: Storage capacity [1] exceeded while writing value of size [1] from position [1]. This is an internal error, if you see it please report it as an issue on the Stan github repository. (found before start of program)
Before #1305, a different kind of error could happen:
parameters {
array[1] real a;
}
{ "a": [] }
Running this with a compiler from before #1305 results in a segmentation fault, after it just doesn't read anything for a.
Expected Behavior:
An error when the transform_inits var context has data of the wrong size (or, possibly, wrong shape? it seems a lot of R code is relying on us not being too picky about the shapes here...)
Current Behavior:
See https://github.com/stan-dev/stan/issues/3182.
In short,
transform_inits
will happily read in a var_context object which is the wrong size. For example:After #1305, this will read in a value for
a
even though one isn't expected, causing thestan::io::serializer
to run out of room when trying to write the value forb
, yielding an error likeBefore #1305, a different kind of error could happen:
Running this with a compiler from before #1305 results in a segmentation fault, after it just doesn't read anything for
a
.Expected Behavior:
An error when the transform_inits var context has data of the wrong size (or, possibly, wrong shape? it seems a lot of R code is relying on us not being too picky about the shapes here...)