Why the stan code of two-way random effects wiener model is error

Oh, you need to wrap multiline for -loops in {}

for (i in 1:N) {
    ....
    ....
}

Also, on RStan there was a problem with i as a variable name, but I think that is fixed.