Open
Description
Description
Given the following code, "failed to produce diagnostic for expression" error occurs when 'if' statement is used in 'repeat'.
Reproduction
func foo<each T>(_ something: repeat Optional<each T>) {
repeat (if let something = each something { print(something) })
// ⛔️ error: failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
}
func fixed<each T>(_ something: repeat Optional<each T>) {
func __printIfNotNil<U>(_ u: U?) { if let u { print(u) } }
repeat (__printIfNotNil(each something))
// ✅ No problems
}
Expected behavior
Successful to compile, or emit a meaningful error message.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
A deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfFeature: expressionsBug → internal error: Failed to produce diagnostic for expressionFeature: generic declarations and typesFeature → statements: 'if' statementsBug: Internal errorFeature → expressions: Pack expansion expressionsFeature → generics: Parameter packsArea → compiler: Semantic analysisBug: Unexpected error