stanc3 icon indicating copy to clipboard operation
stanc3 copied to clipboard

Identifier clash when Stan model file name is the same as distribution

Open jussihuotari opened this issue 4 years ago • 2 comments

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);
}

jussihuotari avatar Nov 26 '20 20:11 jussihuotari

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?

rok-cesnovar avatar Dec 08 '20 10:12 rok-cesnovar

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

WardBrian avatar Feb 09 '22 15:02 WardBrian