Usage of an if/else expression in a generic result builder that implements buildEither(first:) and buildEither(second:) fails to typecheck and crashes the Swift 6 compiler. It compiles fine on the Swift 5 compiler.
Reproduction
@resultBuilder
public enum ValueBuilder<Value> {
public static func buildBlock(_ value: Value) -> Value {
value
}
public static func buildEither(first value: Value) -> Value {
value
}
public static func buildEither(second value: Value) -> Value {
value
}
}
func build<Value>(@ValueBuilder<Value> _ build: () -> Value) -> Value {
build()
}
let result = build {
if 32.isMultiple(of: 2) {
"hello"
} else {
"world"
}
}
Description
Usage of an if/else expression in a generic result builder that implements
buildEither(first:)
andbuildEither(second:)
fails to typecheck and crashes the Swift 6 compiler. It compiles fine on the Swift 5 compiler.Reproduction
Stack dump
Expected behavior
Usage of an if/else expression in the result builder should compile.
Environment
swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1) Target: arm64-apple-macosx14.0
Additional information
No response