swiftlang/swift
Vedi su GitHubDiagnostic for use of plain protocol name in type position should suggest `some` or `any`
Open
#68.284 aperta il 1 set 2023
bugcompilerdiagnostics qualityexistentialsfix-itsgenericsgood first issueopaque typesswift 5.9type checkertypes
Metriche repository
- Star
- (69.989 star)
- Metriche merge PR
- (Merge medio 8g 17h) (510 PR mergiate in 30 g)
Descrizione
The following code is invalid:
protocol P {
associatedtype A
}
func generic(value: P) {}
The compiler currently produces the error message Use of protocol 'P' as a type must be written 'any P' with a fix-it to insert the any keyword.
However, a different (and often better!) fix here is to use the some keyword. The error message should be re-worded to prompt the programmer to consider any or some, and there should be two notes, each with a fix-it to insert any or some, respectively.