Skip to content

[SR-13148] Add special-case diagnostic when detecting request for Comparable synthesis for structs #55595

Closed
@typesanitizer

Description

@typesanitizer
Previous ID SR-13148
Radar rdar://problem/65116465
Original Reporter @typesanitizer
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, TypeChecker
Assignee @theblixguy
Priority Medium

md5: 4bb991b5e9e2dccaaee344947a743120

Issue Description:

struct S : Comparable { // error: type 'S' does not conform to protocol 'Comparable'
  var x: Int
} 

Maybe it should look something like (straw-man suggestion):

synthesizing Comparable conformances is not supported for structs

Bit of a tangent but... this limitation is just plain weird, given that we support Comparable derivation for enums with associated fields:

enum E : Comparable {
  case e(Int, Int) // Just Works
} 

Should one use single-case enums instead of structgs to get the sweet, sweet conformance synthesis? �

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationimprovementtype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions