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-7611] Incorrect compiler error to mark try for not throwing function #50153

Closed
purpleblues opened this issue May 5, 2018 · 0 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@purpleblues
Copy link

Previous ID SR-7611
Radar None
Original Reporter @purpleblues
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 9.3(9E145), Swift 4.1

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

md5: 9baa80becbe1a0f0644b8faec334d7eb

duplicates:

  • SR-1534 Error: Call is to rethrows function, but a defaulted argument function can throw

Issue Description:

I'm implementing simple quicksort function like below.

import Foundation

extension Array where Element: Comparable {
    
    func quicksorted(by areInIncreasingOrder: (Element, Element) throws -> Bool = (<)) rethrows -> Array {
        
        guard let pivot = self.first else {
            return self
        }
        
        let rest = self.dropFirst()

        return try rest.filter { try areInIncreasingOrder($0, pivot) }.quicksorted(by: areInIncreasingOrder)
            + [pivot]
            + rest.filter { try !areInIncreasingOrder($0, pivot) }.quicksorted(by: areInIncreasingOrder)
    }
    
}


let arr = [5,2,5,7,4,8,0,6,4,1,2,3,3,6,3]

print(arr.quicksorted())

This code causes compiler error that says "Call can throw but is not marked with 'try'" even that the operator `<` is not a throwing function.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

1 participant