Skip to content

Failed to produce diagnostic - using Set instead of Array #92450

Description

@vinivendra

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage neededThis issue needs more specific labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions