It is not explicitly stated in the definition of MutableCollection, but the part where it states that:
a[i] = x
let y = a[i]
// Must be equivalent to:
a[i] = x
let y = x
Could be seen as not invalidating indices stored priorly the operation took effect.
The MutableCollection definition though talks about “same position” not “same index”, which could be ambiguous.
Indeed it should explicitly state that previously stored indices must not be invalidated when the subscript mutator is used.
Exactly as you said it.
That is to resolve any possible ambiguity leading to potential MutableCollection implementations where “distance” might be seen as the offset of the index from startIndex, making perfectly fine doing this:
let clone = a
let i = a.index(a.startIndex, offsetBy: 3)
a[i] = newValue
// a copies its storage, clone
// retains old storage
let j = a.index(a.startIndex, offsetBy: 3)
let y = a[j]
// y == newValue
let x = a[i]
// runtime error cause i is no longer valid
// or worse x == oldValue cause i points to
// the old storage kept alive by clone.
That interpretation of MutableCollection might also lead to implementations were it would not be possible to fast-iterate indices and using its mutator subscript inside the loop.
Anyway for sure in the case of Dictionary the index based subscript mutator might end up removing a key-value pair and modifying another element already present in the Dictionary at a different “position” than the one specified in the subscript.
Thus ending up affecting the count of elements of the dictionary —which is an operation prohibited by MutableCollection— and also breaking the other rule about the “position” of the element mutated.