Description
I was changing an algorithm to use an Array instead of a Set, and halfway through I got the error "Failed to produce diagnostic for expression; please submit a bug report...".
Reproduction
Here's the algorithm (reduced to a simpler example). The Set([0]).union($0) expression should be an Array, not a Set, but the compiler couldn't diagnose that.
import Foundation
func subsetsWithDup(_ nums: ArraySlice<Int>) -> Set<Array<Int>> {
let remainingSubsets: Set<Array<Int>> = []
return remainingSubsets.union(
(remainingSubsets.map { Set([1]).union($0) }))
// Should be:
// return remainingSubsets.union(
// (remainingSubsets.map { [1] + $0 }))
}
Expected behavior
I expected the compiler to warn me that the expression's type is wrong, and say what it expected it to be.
Environment
Xcode 27.0, on macOS 27.0. Build Settings lists Swift Language Version as Swift 5.
Additional information
No response
Description
I was changing an algorithm to use an Array instead of a Set, and halfway through I got the error "Failed to produce diagnostic for expression; please submit a bug report...".
Reproduction
Here's the algorithm (reduced to a simpler example). The
Set([0]).union($0)expression should be an Array, not a Set, but the compiler couldn't diagnose that.Expected behavior
I expected the compiler to warn me that the expression's type is wrong, and say what it expected it to be.
Environment
Xcode 27.0, on macOS 27.0. Build Settings lists Swift Language Version as Swift 5.
Additional information
No response