Question solved: At the end this is found to be due to multiplying a constant with a vector, while the error report is a bit distracting (in line much ).
for i in 1:nDemes
println("deme### ", i)
NDeme = N_vec[i]
println("begin_NDeme ",NDeme)
#error reported in this line
x = D[i]
xwt = x[end,t-1]
X = x[1:end-1,t-1]
if !isempty(X)
ss=xwt*s0
xx=X+ss.*X #but actually is caused by this line
...
Instead of editing your original question to put the solution, it can be much more helpful to post the solution as a new post — you can even mark it with a to say it’s solved. That way folks who have similar issues can continue to read, understand, and even find the thread from Google in the future.