Closed Alex-Cremers closed 2 years ago
Thanks @Alex-Cremers. I can confirm this is a bug. Moving this issue to stanc3, where it will be addressed.
I believe we can fix this by adding it to the backend specific list here, so it will be mangled
The documentation page is outdated--the "backend language" keywords are no longer reserved. EDIT: Looking again, the page says "It is legal to name a variable any of the following names" so I guess it's not outdated, just irrelevant.
context
should not be reserved at all. This is a mistake in the codegen backend resulting in ambiguous naming. I'm working on a fix right now.
Summary:
Naming a variable "context" in the data block leads to obscure errors when compiling, so "context" should probably listed as a reserved name.
Description:
Naming a variable "context" in the data block leads to obscure errors when compiling. Naming a variable "context" in the parameters block doesn't cause any issue however. However, "context" is not listed as a reserved name in the manual (see here), and the errors returned by rstan and cmdstanr are not particularly helpful.
Reproducible Steps:
Model doesn't compile:
Model compiles without any problem:
Current Output:
I tried both rstan (v2.29.0.900) and cmdstanr (with cmdstan v2.29.2), both return different errors, neither of which is particularly helpful (although cmdstan at least mentioned
context__
andvar_context
, which helped me figure out what was wrong).