Skip to content

Correctly set the FunctionRefKind for enum element patterns #77803

Open
@hamishknight

Description

@hamishknight

Currently we set FunctionRefKind::Compound for EnumElementPatterns to avoid needing to match labels in the solver. We instead ought to be setting the right kind and properly handling the label matching in the solver.

While here it also looks like the compound naming needs fixing too, e.g we currently allow this:

struct S: Equatable {
  static func bar(x: Int) -> Self { fatalError() }
  public static func == (_: Self, _: Self) -> Bool { false }
}

func foo(_ x: S) {
  _ = {
    switch x {
    case .bar(x:)(x: 0):
      break
    default:
      break
    }
  }
}

rdar://140415944

Metadata

Metadata

Assignees

Labels

accepts invalidBug: Accepts invalidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexpressionsFeature: expressionsfunction referencesFeature: function references as in 'foo(bar:baz:)'swift 6.0type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions