Rstan compile error line number doesn't match with text file

I’m using rstan, with my codes saved in a “.stan” file. I usually use the following codes to compile the model

mod1 <- stan_model(file = "xxxx.stan")

However, I noticed that in the error message, the line numbers don’t match with what I have in my stan file at all. I have to guess which line exactly has got the error and try to fix them through trial and errors. This is really frustrating. I’d like to ask how rstan counts line number? I’ve searched the forum, and saw a few posts. But none of them could solve my question, so I decided to ask again.

Here’s a list of past posts I saw:

No reply for this one: Stan Runtime Error Line Number
A similar question here but later it seems that’s not an issue after all: New line reference system for errors seems confusing

In this post, it’s said that rstan counts line number in the same way as a usual text editor. However, this definitely isn’t what I’m seeing. How does Stan count lines

Can you share a stan model that exhibits this behavior for you?