stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.02k stars 264 forks source link

Patch stanc to allow lpmf with nested int array #1057

Closed andrjohns closed 1 year ago

andrjohns commented 1 year ago

@hsbadr

The 2.26 version of stanc has a bug where int[,] arguments are not treated as valid for lpmf UDFs, causing parse errors like the following:

> testcode <- "
+ functions {
+   real Dirichlet_Multinomial_lpmf(int[,] X, vector eta) {
+     return 0;
+   }
+ }
+ "
> rstan::stanc(model_code = testcode)
Error in rstan::stanc(model_code = testcode) : 0

Semantic error in 'string', line 2, column 2 to line 4, column 3:

Probability mass functions require integer variates (first argument). Instead found type int[,].

This PR updates the stanc.js with a patch for allowing nested arrays up to 3 dims

This is needed for the MADPop reverse dependency with 2.26.