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-7878] Incorrect Closure Signature with Void crashes Compiler #50413

Open
palimondo mannequin opened this issue Jun 5, 2018 · 3 comments
Open

[SR-7878] Incorrect Closure Signature with Void crashes Compiler #50413

palimondo mannequin opened this issue Jun 5, 2018 · 3 comments
Assignees
Labels
access control Feature → modifiers: Access control and access levels bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.2

Comments

@palimondo
Copy link
Mannequin

palimondo mannequin commented Jun 5, 2018

Previous ID SR-7878
Radar None
Original Reporter @palimondo
Type Bug

Attachment: Download

Environment

Swift dev toolchain from 30-05-2018. Xcode 9.4

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, CompilerCrash
Assignee @xedin
Priority Medium

md5: 9124c3828d567af6e86d6c5b6445cecd

Issue Description:

Following code crashes the Swift compiler with "Command failed due to signal: Abort trap: 6":

extension Sequence {
    @_inlineable
    public func prefixSC(while predicate: @escaping Predicate)
    -> UnfoldSequence<Iterator.Element, Void> {
        var iterator = makeIterator()
        return sequence(state: (), next: {
            (state: Void) -> Iterator.Element? in
//            (state: inout Void) -> Iterator.Element? in
//            _ in
            guard let e = iterator.next() else { return nil }
            return predicate(e) ? e : nil
        })
    }
}

The code is incorrect. The line `(state: Void) -> Iterator.Element? in` is missing `inout` before the Void. Spelling it correctly or letting the signature be inferred with `_ in` as seen in the comments works fine.

Same code isn't crashing in 4.2.1 that ships with Xcode 9.4, so this seems to be a regression.

@belkadan
Copy link
Contributor

belkadan commented Jun 5, 2018

Sorry, where is the Predicate type defined?

@palimondo
Copy link
Mannequin Author

palimondo mannequin commented Jun 5, 2018

Sorry, my bad!

public typealias Predicate = (Iterator.Element) -> Bool

The example comes from https://github.com/palimondo/MandelbrotSwifty

@slavapestov
Copy link
Member

No longer crashes but produces a lousy diagnostic:

bad.swift:4:6: warning: '@_inlineable' has been renamed to '@inlinable'
    @_inlineable
     ^~~~~~~~~~~
     inlinable
bad.swift:8:42: error: cannot convert value of type '(inout Void) -> Self.Element?' to expected argument type '(inout Void) -> _?'
        return sequence(state: (), next: {
                                         ^

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added regression swift 4.2 access control Feature → modifiers: Access control and access levels and removed 4.2 regression labels Nov 19, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
access control Feature → modifiers: Access control and access levels bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.2
Projects
None yet
Development

No branches or pull requests

3 participants