Regression in Set with Swift 5.5

@nnnnnnnn brought up that Sequence.min/max implementations in the stdlib do not specify which element they return if there are duplicates. I think they should!

This would also be a chance to make this consistent. Currently, the top-level max functions return the last dupe, while Sequence.max returns the first. We should choose one behavior and consistently stick to it. (Given that the behavior of the top-level max is documented, Sequence.max should probably adopt it, too.)

9 Likes

So the Swift 5.6 release process was just published. Do you think there is any way this would make it into that release?

What would be the next step? A pitch thread to try to gather more changes? At first I thought this would just be changes in documentation, but if the idea is to also change the behavior at the same time, some actual implementation will be required :thinking:

The implementation changes for Set are done.

1 Like

True, but changes to Sequence.min/max are probably not.

I don't believe the documentation updates have been done yet, however.

I don't see why a narrow and relatively uncontroversial proposal that ties down behavior through doc updates couldn't fit into 5.6! I don't think changing the behavior of Sequence.max would complicate things, either.

S-E proposal scheduling bottlenecks could happen, of course -- it wouldn't be the end of the world if the updates get delayed by one release, as long as they eventually happen.

1 Like