Why this code snippet won't compile in Xcode 11.2.1? (compiles in Xcode 11.0)

The following code compiles in Xcode 11.0, but it won't compile in Xcode 11.2.1, why?
The compile emits an error message " ambiguous reference to member '==' ".

P.S. If I moved the code out of the function-builder block, there is no compile error any more. It seems that the compiler behavior has changed in the function-builder block.

import Foundation

public struct LayoutStmt {
  public init() {}

public struct LayoutStmtGroup {
  public init(stmts: [LayoutStmt]) {}

public struct LayoutBuilder {
  public static func buildBlock(_ stmts: LayoutStmt...) -> LayoutStmtGroup {
    return LayoutStmtGroup(stmts: stmts)


public func AutoLayout(@LayoutBuilder builder: () -> LayoutStmtGroup) -> LayoutStmtGroup {
  let group = builder()

  return group

public class Anchor {
  public init() {}

func ==(anchor: Anchor, value: Double) -> LayoutStmt {
    return LayoutStmt()

let anchor = Anchor()

AutoLayout {
  anchor == 2 // compiler error: ambiguous reference to member '=='
  anchor == 3

@Joe_Groff Can you help to take a look at this issue? Thanks!

If you haven't yet, please file a bug at bugs.swift.org. Thanks for bringing this to our attention!

Hmm, it's working on "master". It may very well be the same issue as in https://bugs.swift.org/browse/SR-11614

I add another (maybe same reason) compile error case in this issue (https://bugs.swift.org/browse/SR-11888). If the improved playground also works on swift master branch, just close the issue. Thanks.

It is ridiculous! I also faced with functionBuilder regression on Nov, 1, 2019 when I updated to Xcode 11.2 from 11.1. I filed a bug https://bugs.swift.org/browse/SR-11694 but it is still not fixed in Xcode 11.3.1! I don't understand why Apple won't fix it! It is common feature which is already used by a lot of libraries!

Perhaps because function builders are not officially supported yet?

Works fine on master. Could you try again with the most recent snapshot?

Apple use it in production with SwiftUI, why I should not use it? I should sit calm and wait for years? Especially if it works fin in Swift 5.1.0 and then by someones broken hands it stops working in 5.1.1...5.1.3 why I should be silent? I really want it to be fixed to use it in my libs.

It works in Swift 5.2 beta snapshot which is available since Jan 22, thank you!

1 Like


Yes, Apple uses it in their closed source library. The attribute itself is underscored and the feature has not yet made it through evolution. You can of course use it, but at your own risk.

Yeah that's right that I use it at my own risk since it is underscored, but I definitely can complain that it is stopped working especially if it doesn't work for three month already.

Because it's not officially supported, so, all bets are off if and when it will work at any one time. SwiftUI and Combine, being private Apple frameworks, get released when Xcode/frameworks are released, and it is tested as part of the Xcode release process, which only happens a few times a year. Any other time, you're on your own as to it working from Swift release to Swift release, as you've experienced, until it is an officially support by the open-source team. Yes, if you want consistency over time, you should remain calm and wait for years, if that is what it takes.

1 Like

No man, this is not how it works in open source. If something is broken in beta I should annoy everyone until it is fixed because only in this case I will get that working soon.

functionBuilder is not open-source.

the same for closed source

Squeaky wheel gets the hot sauce.