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-7729] Type deduction failure #50269

Open
dabrahams opened this issue May 20, 2018 · 3 comments
Open

[SR-7729] Type deduction failure #50269

dabrahams opened this issue May 20, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-7729
Radar rdar://problem/40422845
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: a4de9b7079796c0db27f161be811497c

Issue Description:

I think this should compile without the explicit cast to `Optional`, but it does not:

extension Collection {
    public func lastIndex(
        where predicate: (Element) throws->Bool
    ) rethrows -> Index? {
        return try indices.reduce(nil) {
            r, i in try predicate(self[i]) ? i /*as Optional*/ : r
        }
    }
}

error: value of optional type 'Self.Index?' not unwrapped; did you mean to use '!' or '?'?
            r, i in try predicate(self[i]) ? i /*as Optional*/ : r
                                                                 ^
                                                                  !
@belkadan
Copy link
Contributor

cc @rudkx, @xedin

@rudkx
Copy link
Member

rudkx commented May 21, 2018

Yes, it looks like we have a problem in our handling of parameters to closures.

@rudkx
Copy link
Member

rudkx commented May 21, 2018

@swift-ci create

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants