Skip to content

Improve diagnostic when attempting to pattern match on static func #81055

Open
@hamishknight

Description

@hamishknight

For e.g:

struct S {
  static func foo(_ x: Int) -> S { .init() }
}

func bar(_ x: S) {
  switch x {
  case .foo(let x): // error: 'let' binding pattern cannot appear in an expression
    ()
  }
}

We ought to be able to improve the diagnostic to point out that you're trying to pattern match a function argument rather than an enum case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationimprovementpattern matchingFeature: pattern matchingtype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions