Just to expand a bit on what @aakhmetz wrote: the CRAN version of rstan is unfortunately quite old. There are stupid technical reasons that currently prevent us from updating the CRAN version, but we are trying to sort this out. If you need access to recent features, you can either use cmdstanr or install latest rstan via https://mc-stan.org/r-packages/
In your specific situation, you can get exactly equivalent model that works with 2.21 by writing
I think the parser is getting confused when there’s a vertical bar in something that’s not recognized as a probability density function. It gives a more reasonable error if you write