stanc3
stanc3 copied to clipboard
Identifier clash when Stan model file name is the same as distribution
Got compile-time message in Rstan: "... In this case, the new compiler did not work like we hoped."
Semantic error in 'string', line 10, column 6 to column 12:
Identifier 'normal' clashes with model name.
This seems to happen when the Stan model's file name matches the model's distribution. Originally got this with beta_proportion
but as a minimal example I used:
Compile
n <- 100
stan_data <- list(N = n, y = rnorm(n, 5, 2))
fit <- stan("normal.stan", data = stan_data)
Model
data {
int<lower=0> N;
vector[N] y;
}
parameters {
real mu;
real<lower=0> sigma;
}
model {
y ~ normal(mu, sigma);
}
Hi, thanks for the report. This is a restriction set by stanc3. We could take this opportunity and revisit this restriction.
@seantalts @VMatthijs would any of you know why this restriction was put in place?
I know this issue is old at this point, but in the binary compiler we add _model
to the name of the file, but not in the JS compiler. Is there a reason for the inconsistency? @rok-cesnovar