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-11628] Function Builder not working when only one value? #54039

Closed
swift-ci opened this issue Oct 17, 2019 · 5 comments
Closed

[SR-11628] Function Builder not working when only one value? #54039

swift-ci opened this issue Oct 17, 2019 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11628
Radar rdar://problem/56340587
Original Reporter Aiur (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 11.0 (11A420a)

Mac OS 10.15(19A583)

Swift 5.1

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee Aiur (JIRA)
Priority Medium

md5: 1bf5470a323a6183a8d22003fcbd43c0

is duplicated by:

  • SR-11792 Function Builder not working with single item in closure
  • SR-12632 @_functionBuilder not working with one value

Issue Description:

I have a functionBuilder

@_functionBuilder
struct MyBuilder {
    static func buildBlock(_ numbers: Int...) -> Int {
        var result = 0
        for number in numbers {
            result += number * 2
        }
        return result
    }
}

Function

func myFunc(@MyBuilder builder: () -> Int) -> Int {
    builder()
}

Use

let a = myFunc {
    10
    20
}
print(a) // print 60 is work!

But

let b = myFunc {
    10
}
print(b) // print 10?

Why is b not 20?

I try add other buildBlock

static func buildBlock(number: Int) -> Int {
    return number * 2
}

But not working 🙁

It is a bug ?

@belkadan
Copy link
Contributor

@rjmccall, I think you had the bug for this? Single-expression closures not getting function-built properly?

@rjmccall
Copy link
Member

I think @xedin is working on it.

@swift-ci
Copy link
Collaborator Author

Comment by Gurami Jobava (JIRA)

@rjmccall Any updates on this please?

@rjmccall
Copy link
Member

It's being worked on. I have to remind you that `@_functionBuilder` is still a preview feature, though, so priority is being given to other improvements that benefit the current official clients.

@xedin
Copy link
Member

xedin commented Jan 16, 2020

Fixed by #28837 Aiur (JIRA User) please use a next available nightly snapshot of master to verify and close.

@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

4 participants