swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.69k stars 10.39k forks source link

[SR-11497] Duplicated spacer leads to 'Ambiguous reference to member 'buildBlock()' #53898

Open swift-ci opened 5 years ago

swift-ci commented 5 years ago
Previous ID SR-11497
Radar rdar://problem/55560957
Original Reporter stevex (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, FunctionBuilder | |Assignee | None | |Priority | Medium | md5: 5a96ef644edd478a2faa4bdea83ca57c

Issue Description:

In a nutshell:

struct ContentView : View {
    var body: some View {
        VStack {
            Spacer()
            HStack {
                Spacer()  // comment out this line, and the error goes away
                Spacer()
                Text("X")
                Spacer()
                Text("X")
                Spacer()
                Text("X")
                Spacer()
                Text("X")
                Spacer()
                Spacer()
            }
            Spacer()
        }
    }
}

Attempting to use spacers in an HStack as a layout shortcut .. having two Spacer at the start produces the error 'Ambiguous reference to member buildBlock()'. Comment out the first line and it builds successfully.

Sample project attached.

belkadan commented 5 years ago

@rjmccall, do you have a dup for this?

belkadan commented 5 years ago

@swift-ci create

rjmccall commented 5 years ago

No, I don't think so.

This is just a specific bad diagnostic for having more elements than the function builder allows. (Allowing arbitrary element counts is also a problem, of course.)