Diagnostic for use of plain protocol name in type position should suggest `some` or `any`

Open
#68,284 19 comments 0 reactions 1 assignee View on GitHub

@yyoungbash is already working on this.

Since Oct 29, 2025.

Assessment

This issue has not been assessed yet.

Description

bug compiler diagnostics quality existentials fix-its generics good first issue opaque types swift 5.9 type checker types

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.

Dominant language
Swift
Stars
70.4k
Forks
10.8k
Avg merge
2d 2h
Merged PRs (30d)
461

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from swiftlang/swift

All issues in swiftlang/swift

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.