SILFunction type mismatch compiler bug

If the type is very complicated(Contains type cross different module), it will build fail with a swift compiler crash saying "SILFunction type mismatch".

The concrete issue is one will have @out sil mark and one wouldn't.

You can find the min reproducible env and more detailed introduction on the Github Issue

Filed the bug via SILFunction type mismatch · Issue #65849 · apple/swift · GitHub

If you are curious in how I found this bug, I can only say that it is a business secret.

All I can tell is it was originally from SwiftUI
SwiftUI.View protocol have a func called _makeViewList(view:inputs:)

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@_typeEraser(AnyView) public protocol View {
  static func _makeViewList(view: SwiftUI._GraphValue<Self>, inputs: SwiftUI._ViewListInputs) -> SwiftUI._ViewListOutputs
  associatedtype Body : SwiftUI.View
  @SwiftUI.ViewBuilder @_Concurrency.MainActor(unsafe) var body: Self.Body { get }
}

And it will return _ViewListOutputs which is the type B in the bug demo.

1 Like