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-11657] .first resolves to first(where:) on LazyMapSequence instead of its first property #54068

Open
swift-ci opened this issue Oct 23, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself standard library Area: Standard library umbrella type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11657
Radar rdar://problem/56542661
Original Reporter Lance (JIRA User)
Type Bug
Environment

Xcode 11.1 (11A1027)

Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: d9ce902e3846a9c915f4e46e78045d50

Issue Description:

let xs = [1,2,3]
 
let a = xs.enumerated().lazy.compactMap { t in t.offset % 2 == 0 ? t.offset : nil }.first
let b = zip(xs.indices, xs).lazy.compactMap { t in t.0 % 2 == 0 ? t.0 : nil }.first
let b = xs.indices.lazy.compactMap { t in t % 2 == 0 ? t : nil }.first

In the code above, both `a` and `b` are functions, only `c` is an `Int?` as expected. There seems to be a type checker bug here.

@belkadan
Copy link
Contributor

@swift-ci create

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 6, 2019

Comment by Kyle Macomber (JIRA)

It looks like this is happening because `enumerated` and `zip` are sequences and not collections.

@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. compiler The Swift compiler in itself standard library Area: Standard library umbrella type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants