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
[SR-4240] drop(while:) after prefix() on pure Sequence looses the prefix #46823
Comments
I don’t have Swift 3.1 to test this myself, but I think this would be the test case: let xs = sequence(first: 1, next: {$0 < 10 ? $0 + 1 : nil}) // Equivalent to 1...10
let ys = xs.prefix(3).drop(while: {$0 < 7})
Array(ys) // should be [], but I guess it’s [7, 8, 9, 10] Pinging CodaFi (JIRA User) who introduced this bug addressing comments by @gribozavr. |
This tracks 3.1 #8141 |
Works for me:
|
@dabrahams, looks like you've tested this on master after 81968e2 already landed… Should I reopen this? Or did you mean to resolve it as fixed instead of can't reproduce? |
You're quite right; this should be resolved as fixed. I see that shipping Swift gets this wrong. I don't really understand why, but I suppose it doesn't matter. |
@dabrahams What went wrong, process-wise, that this shipped in 3.1?! //@airspeedswift |
The fix was integrated into Swift 3.1 branch and is waiting for a release in version 3.1.1. This hasn't shipped yet as of Xcode 8.3.2. |
I stand corrected. The fix is in Xcode 8.3.2. Sorry for the confusion. Closing. |
Environment
Swift 3.1beta
Additional Detail from JIRA
md5: cee58ba90aa08a68ae18b33517c07038
Issue Description:
Looking at the source code, I believe the #4346 introduced a bug in stdlib/public/core/Sequence.swift, where the calling
drop(while: )
afterprefix()
on a pure Sequence (Collections override this implementation) would loose the prefix, because in the internaldrop(while: )
override grabs the underlying base iterator from_PrefixSequence
and just wraps it in the_DropWhileSequence
.The text was updated successfully, but these errors were encountered: