Identifier expected after sized type in local (or model block) variable declaration. (No transformations/constraints allowed.)

I am having trouble writing a user-defined function. Here is such a function that does work:

 functions{
   array[,] real foo(real mu, real sigma){
     array[2,2] real v;  
     v[1,1] = sigma + mu;;
     v[1,2] = sigma - mu;
     v[2,1] = sigma^2;
     v[2,2] = mu^2;
     return v;
   }
 }

When I run this using rstan::expose_stan_functions I get, correctly
` foo(mu = 2, sigma = 5)
[[1]]
[1] 7 3

[[2]]
[1] 25 4
But if I add a line real<lower = 0> A;`

 functions{
   array[,] real foo(real mu, real sigma){
     array[2,2] real v;
     real<lower = 0> A;
     A = sigma + mu;
     v[1,1] = A;
     v[1,2] = sigma - mu;
     v[2,1] = sigma^2;
     v[2,2] = mu^2;
     A = sum(v)
     return v;
   }
 }

I get the error:
Identifier expected after sized type in local (or model block) variable declaration. (No transformations/constraints allowed.)

I find the error message incomprehensible. Can someone tell me what I am doing wrong? Thanks.

As the error message says: (No transformations/constraints allowed.)

These are only used to constrain parameters in the parameters block, or to check validity in the transformed parameters block.

There’s no way to specify/enforce a constraint within a function (or for a transformation of parameters)

Many thanks for such a quick response. It has solved my problem.

I still don’t understand the first part of the error message.