Skip to content

Duplicate statement diagnostics in result builder #77453

Closed
@hamishknight

Description

@hamishknight

The following gives a duplicate diagnostic:

@resultBuilder
struct Builder {
  static func buildBlock<T>(_ components: T...) -> T {
    components.first!
  }
  static func buildEither<T>(first component: T) -> T {
    component
  }
  static func buildEither<T>(second component: T) -> T {
    component
  }
}

func takesClosure(_ fn: () -> Void) -> Int? { nil }

@Builder
func foo() -> Int {
  if let x = takesClosure {} { // 2x warning: trailing closure in this context is confusable with the body of the statement
    0
  } else {
    1
  }
}

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions