Skip to content

[stdlib] Remove the UnboundedRange_ enum #18649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

benrimmington
Copy link
Contributor

This pull request changes the UnboundedRange typealias to (Never) -> PartialRangeFrom<Never>, using the Never: Comparable conformance from SE-0215.

@benrimmington
Copy link
Contributor Author

benrimmington commented Aug 11, 2018

Outdated comment

@airspeedswift @dabrahams

I prefer the empty subscript operations from your manifesto, as discussed in the Gold-plating UnboundedRange forum topic.

If the unbounded range operator is valid only within a collection's subscript, could the typealias be moved into an extension?

extension Collection {
  /// A range expression that represents the entire range of a collection.
  public typealias UnboundedRange = (Index) -> PartialRangeFrom<Index>
}

@available(swift, deprecated: 5.0, message:
  "The unbounded range operator is valid only within a collection's subscript.")
public typealias UnboundedRange = (Never) -> PartialRangeFrom<Never>

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from 85e0938 to c0b7eb8 Compare September 28, 2018 17:50
@benrimmington
Copy link
Contributor Author

benrimmington commented Sep 28, 2018

Outdated comment

@airspeedswift @dabrahams

Please let me know if you have any interest in this pull request.

I can also write a proposal (and implementation) to deprecate UnboundedRange in favor of empty subscripts. But you might have already decided against that, as your manifesto predates UnboundedRange.

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch 2 times, most recently from 4722517 to 4254305 Compare November 10, 2018 18:44
@benrimmington
Copy link
Contributor Author

@lorentey Please take a look at this pull request.

Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good idea to me, but @airspeedswift is more familiar with these!

@lorentey
Copy link
Member

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c0b7eb8524a74694f4eeb33a82d2121d488051b0

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from 4254305 to a791ec2 Compare November 14, 2018 19:04
@airspeedswift
Copy link
Member

@swift-ci please test source compatibility

@benrimmington
Copy link
Contributor Author

benrimmington commented Nov 14, 2018

Outdated comment

There were some known failures (#20575 and SR-9252).

Failures:
  FAIL: Kickstarter-ReactiveExtensions, 4.0, 6b7887, ReactiveExtensions-TestHelpers-iOS, generic/platform=iOS
  FAIL: Kickstarter-ReactiveExtensions, 4.0, 6b7887, ReactiveExtensions-iOS, generic/platform=iOS
  FAIL: ReactiveCocoa, 4.0, 72dd20, ReactiveCocoa-watchOS, generic/platform=watchOS
  FAIL: ReactiveCocoa, 4.0, 72dd20, ReactiveCocoa-tvOS, generic/platform=tvOS
  FAIL: ReactiveCocoa, 4.0, 72dd20, ReactiveCocoa-iOS, generic/platform=iOS
  FAIL: ReactiveCocoa, 4.0, 72dd20, ReactiveCocoa-macOS, generic/platform=macOS
  FAIL: ReactiveSwift, 4.0, 46fb4d, ReactiveSwift-watchOS, generic/platform=watchOS
  FAIL: ReactiveSwift, 4.0, 46fb4d, ReactiveSwift-tvOS, generic/platform=tvOS
  FAIL: ReactiveSwift, 4.0, 46fb4d, ReactiveSwift-iOS, generic/platform=iOS
  FAIL: ReactiveSwift, 4.0, 46fb4d, ReactiveSwift-macOS, generic/platform=macOS
  FAIL: Tagged, 4.1, 6e0798, Swift Package
  FAIL: Tagged, 4.1, 6e0798, Tagged-Package, generic/platform=watchOS
  FAIL: Tagged, 4.1, 6e0798, Tagged-Package, generic/platform=tvOS
  FAIL: Tagged, 4.1, 6e0798, Tagged-Package, generic/platform=iOS
  FAIL: Tagged, 4.1, 6e0798, Tagged-Package, generic/platform=macOS

I couldn't see a way to easily clone or search all projects in the source compatibility suite, so I don't know if any of them are using UnboundedRange. But I did find [...] in some stdlib tests.

./swift/utils/run-test \
  --build-dir ./build/Ninja-DebugAssert/swift-macosx-x86_64/ \
    ./swift/test/api-digester/stability-stdlib-abi.swift \
    ./swift/test/api-digester/stability-stdlib-source.swift \
    ./swift/test/stdlib/LazySlice.swift \
    ./swift/test/stdlib/NSSlowString.swift \
    ./swift/test/stdlib/NSStringAPI+Substring.swift \
    ./swift/test/stdlib/StringCompatibilityDiagnostics.swift \
    ./swift/test/stdlib/StringCompatibilityDiagnostics4.swift \
    ./swift/test/stdlib/StringIndex.swift \
    ./swift/test/stdlib/subString.swift \
    ./swift/validation-test/stdlib/Array.swift.gyb \
    ./swift/validation-test/stdlib/ArraySlice.swift.gyb \
    ./swift/validation-test/stdlib/ContiguousArray.swift.gyb \
    ./swift/validation-test/stdlib/String.swift

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from a791ec2 to d0c06bc Compare November 15, 2018 21:27
@xwu
Copy link
Collaborator

xwu commented Nov 15, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a791ec29e10c8b26d49a0e2c10820cbf0f82a685

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a791ec29e10c8b26d49a0e2c10820cbf0f82a685

@benrimmington
Copy link
Contributor Author

@nkcsgexi The api-digester tests have passed, but I'm wondering why something like the following wasn't needed.

TypeAlias UnboundedRange has underlying type change from (UnboundedRange_) -> () to (Never) -> PartialRangeFrom<Never>

@nkcsgexi
Copy link
Contributor

The ABI checker is expected to not have it because we exclude all type alias decls from the module dump. For the source stability checker, i guess we should. Could you file a bug on bugs.swift.org and assign it to me?

@benrimmington
Copy link
Contributor Author

@nkcsgexi Thanks, I've assigned SR-9283 to you.

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from d0c06bc to 46b8181 Compare November 16, 2018 15:46
@benrimmington
Copy link
Contributor Author

@airspeedswift Would it be possible to merge this before the final branching?

@airspeedswift
Copy link
Member

@swift-ci please test

@airspeedswift
Copy link
Member

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d0c06bc5c066f11caa9bc447b7c225d33e8dc3f2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d0c06bc5c066f11caa9bc447b7c225d33e8dc3f2

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from 46b8181 to 385b5b9 Compare November 27, 2018 12:52
@jrose-apple
Copy link
Contributor

@swift-ci please test

@jrose-apple
Copy link
Contributor

@swift-ci Please test source compatibility

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from 385b5b9 to 19b6bd9 Compare December 12, 2018 17:21
@dabrahams
Copy link
Contributor

I could be mistaken, but this PR looks like it removes support for the a[...] syntax without having had any language review. If I'm wrong, where was the review, or where does the syntax support come from (since this PR deletes the func)?

@benrimmington
Copy link
Contributor Author

@dabrahams I believe you are mistaken, because the validation tests which use that syntax are still passing. (I haven't got commit access, so I can't run tests here.) The new typealias is compatible with the existing postfix ... function, because Never conforms to Comparable.

@milseman
Copy link
Member

@swift-ci please test

@milseman
Copy link
Member

@swift-ci please test source compatibility

@dabrahams
Copy link
Contributor

@benrimmington That's cute! Thanks for the explanation.

@benrimmington
Copy link
Contributor Author

@airspeedswift All checks have passed.

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from 19b6bd9 to a607df8 Compare December 13, 2018 16:30
@benrimmington
Copy link
Contributor Author

The baseline ABI/API was regenerated; and a test was recently updated to include UnboundedRange_ in an // expected-note comment. I've pushed an update.

@jrose-apple
Copy link
Contributor

Drive-by testing

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 19b6bd9907048c648d8b3f322da1c810500cd5ef

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 19b6bd9907048c648d8b3f322da1c810500cd5ef

@benrimmington
Copy link
Contributor Author

@jrose-apple Thanks. Should we test source compatibility again?

@jrose-apple
Copy link
Contributor

Nah, it passed and you didn't change anything significant. This one's mostly just to make it mergeable again. (Technically the smoke tests would have been good enough, but I feel weird using those unless the PR is really just test changes or something.)

@benrimmington
Copy link
Contributor Author

The macOS failure was a timeout of an lldb test.

@jrose-apple
Copy link
Contributor

@swift-ci Please test macOS

@benrimmington
Copy link
Contributor Author

@airspeedswift All checks have passed.

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from a607df8 to 326ecc9 Compare December 21, 2018 17:15
@benrimmington
Copy link
Contributor Author

@airspeedswift I can also prepare a PR for the 5.0 branch, if you will approve and merge this one.

@palimondo
Copy link
Contributor

@swift-ci please test

@benrimmington
Copy link
Contributor Author

@airspeedswift Please review

@benrimmington benrimmington force-pushed the remove-the-unboundedrange_-enum branch from 326ecc9 to 31bd6d4 Compare January 17, 2019 20:09
@dabrahams
Copy link
Contributor

What happened here? I loved it once I grokked it!

@benrimmington
Copy link
Contributor Author

@dabrahams It didn't seem like this would be merged, so I ran out of patience and closed it.

@benrimmington benrimmington deleted the remove-the-unboundedrange_-enum branch February 3, 2019 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants