Fail to #include (rstan)

I would like to include this util.stan file

int[] rep_int(int x, int n){
	int out_int[n];

	for(i in 1:n)	out_int[i] = x;

	return out_int;
}

And include it in this way in a stan script

functions{
#include util.stan

I simply added the util.stan file to the inst/stan directory and built the package using Rstudio

image

and I get this error


PARSER FAILED TO PARSE INPUT COMPLETELY
STOPPED AT LINE 1: 
int[] rep_int(int x, int n){
	int out_int[n];

	for(i in 1:n)	out_int[i] = x;

	return out_int;
}





Error in rstan::stanc(file_name, allow_undefined = TRUE, obfuscate_model_name = FALSE) : 
  failed to parse Stan model 'util' due to the above error.
Calls: <Anonymous> -> sapply -> lapply -> FUN -> <Anonymous>
Execution halted
ERROR: configuration failed for package ‘ARMET’
* removing ‘/stornext/Home/data/allstaff/m/mangiola.s/R/x86_64-pc-linux-gnu-library/3.6/ARMET’
* restoring previous ‘/stornext/Home/data/allstaff/m/mangiola.s/R/x86_64-pc-linux-gnu-library/3.6/ARMET’

Exited with status 1.

Am I missing something?

Do you have multiple functions blocks perhaps? A while ago someone else had the same error message, and it was due to that.

If not, try to put the code directly in the main stan file instead of using the include, in case it produces a better error message.

The model works fine in the same file. The util.stan just include the function definition without code block

It uses map_rect, I don’t know whether can be a complication.