Fix depth calculations when doing an []= operation