Fix range detector (used when rewriting loop-uses).
Store the new collapse value in a temporary variable since the iterator was being invalidated before being dereferenced.
Store the new collapse value in a temporary variable since the iterator was being invalidated before being dereferenced.