Skip to content
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-6991] prefix(through:) on LazyRandomAccessCollection becomes RandomAccessSlice #49539

Open
weissi opened this issue Feb 13, 2018 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@weissi
Copy link
Member

weissi commented Feb 13, 2018

Previous ID SR-6991
Radar None
Original Reporter @weissi
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @moiseev
Priority Medium

md5: 3aa38e67aaf94cf70aff596c34fd4d3a

Issue Description:

invoking prefix(through: ) on LazyRandomAccessCollection returns a RandomAccessSlice which makes all follow-up operations non-lazy (ie. filter and map materialise an Array)...

Example:

(1...Int.max).lazy.prefix(through: (1...Int.max).index(before: (1...Int.max).endIndex)).filter({ _ in true }).first

will run for a very long time. This can be fixed by an extra .lazy which I believe shouldn't be necessary:

(1...Int.max).lazy.prefix(through: (1...Int.max).index(before: (1...Int.max).endIndex)).lazy.filter({ _ in true }).first

works. Usually, one .lazy works just fine such as this example:

(1...Int.max).lazy.prefix(through: (1...Int.max).index(before: (1...Int.max).endIndex)).lazy.filter({ _ in true }).map({ 1 + $0 }).first
@weissi
Copy link
Member Author

weissi commented Mar 27, 2018

@moiseev this seems to be fixed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant