Skip to content

Compiler fails to produce diagnostic for 'if' statement in 'repeat'. #72253

Open
@YOCKOW

Description

@YOCKOW

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

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexpressionsFeature: expressionsfailed to produce diagnosticBug → internal error: Failed to produce diagnostic for expressiongenericsFeature: generic declarations and typesif elseFeature → statements: 'if' statementsinternal errorBug: Internal errorpack expansionsFeature → expressions: Pack expansion expressionsparameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions