I was wrong. The error is not in the matrix operation, but in the matrix declaration within the loop itself. Here is the test case.
<s>
nulldata 10
loop for i=1..3 -q
matrix a = {1,2}
end loop
</s>