Interesting.
Reduced example:
function tt {
set -x
local -r a=1
local -r b=(1)
local -r c=$(echo 1)
}
}
tt
This prints
+ local -r a=1
+ b=(1)
+ local -r b
++ echo 1
+ local -r c=1
So, when creating a variable when a simple value, the statement is
evaluated as a whole, but when setting an array, it splits into value
assignment and then variable declaration.
I have no idea why this is the case.