Skip to content

Conversation

@calda
Copy link
Contributor

@calda calda commented Apr 19, 2023

This PR cherry picks #64786 into the Swift 5.9 release branch.


Example of #64757:

@resultBuilder
struct VoidBuilder {
    static func buildBlock() -> Void { }
    static func buildPartialBlock<T>(first: T) -> Void { }
    static func buildPartialBlock<T>(accumulated: Void, next: T) -> Void { }
}

final class EscapingWrapper {
    static func wrapper(_ closure: @escaping () -> Void) {
        closure()
    }
}

final class Sample {
    @VoidBuilder
    var void: Void {
        EscapingWrapper.wrapper { [weak self] in
            guard let self else { return } // Unexpected error: Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
        }
    }
}

…closure" error in closure nested in result builder
@calda calda requested a review from a team as a code owner April 19, 2023 15:45
@xedin xedin changed the title [CP] Fix #64757: Unexpected "Implicit use of 'self' in closure" error in closure nested in result builder [5.9] Fix #64757: Unexpected "Implicit use of 'self' in closure" error in closure nested in result builder Apr 19, 2023
@xedin xedin added swift 5.9 🍒 release cherry pick Flag: Release branch cherry picks labels Apr 19, 2023
@xedin
Copy link
Contributor

xedin commented Apr 19, 2023

@calda Please use template for description outlined in https://forums.swift.org/t/swift-5-9-release-process/63557

@xedin xedin requested a review from hborla April 19, 2023 19:22
@calda
Copy link
Contributor Author

calda commented Apr 19, 2023

Updated @xedin

@xedin
Copy link
Contributor

xedin commented Apr 19, 2023

@calda I don’t think this regression is in 5.8, is it? Alex’s changes are only merged to main.

@calda
Copy link
Contributor Author

calda commented Apr 19, 2023

@xedin This is a problem in 5.8, as reported by #64757. The sample code above compiles successfully in 5.7.3 but not 5.8 or 5.9.

You're right that the issue in 5.8 wasn't caused by Alex's change in 2c5b193. My mistake. I'm actually not sure what caused this regression in Swift 5.8, but it must have been something else.

@xedin
Copy link
Contributor

xedin commented Apr 19, 2023

I see, I think it might be caused by the same conceptual problem because closures are still “type-checked separately” (typeCheckClosureBody is called although solver did include the body in inference) during solution application process, we noticed this too late to fix for 5.8.

@xedin
Copy link
Contributor

xedin commented Apr 28, 2023

@swift-ci please test

@calda
Copy link
Contributor Author

calda commented Aug 10, 2023

Closing since Swift 5.9 is pretty close to being released and this CP doesn't seem like it would qualify anymore. Fix will be included in 5.10.

@calda calda closed this Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants