I wonder if it's anything to do with the description in the developer documentation:
Calling this method may invalidate all saved indices of this collection. Do not rely on a previously stored index value after altering a collection with any operation that can change its length.
Would path.remove(at: path.count - 1) be better?
Topic:
UI Frameworks
SubTopic:
SwiftUI