Skip to content

Type deduction nil => (some X)?; 'τ_0_0' in diagnostic #62787

Open
@dabrahams

Description

@dabrahams

With swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0

swift this file

func f() -> some Collection<Int> { [1] }
func g0(x: Bool) -> Optional<some Collection<Int>> {
  f()
}

func g1(x: Bool) -> Optional<some Collection<Int>> {
  x ? f() : nil
}

func g2(x: Bool) -> Optional<some Collection<Int>> {
  if x { return f() }
  return nil // error: generic parameter 'τ_0_0' could not be inferred

Ideally, g2 should compile, and regardless τ shouldn't appear in the diagnostic.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typesliteralsFeature → expressions: Literals such as an integer or string literalopaque typesFeature → types: opaque typesswift 5.7type checkerArea → compiler: Semantic analysistype inferenceFeature: type inference

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions