-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diagnostic for use of plain protocol name in type position should suggest some
or any
#68284
Comments
@hborla |
I’m currently working on fixing this bug in diagnostics as part of the swift mentorship program |
I too want to contribute and get started, I am new to open source, so want to learn and explore this. |
@taevonlewis are you still working on this issue? |
@saehejkang Yes, I am. |
Hi @taevonlewis, are you still working on this? |
@AnthonyLatsis can this be reassigned due to its lack of activity? EDIT Even if this issue is still being worked on, I found some great notes on Diagnostics.md to help me wrap my head around how protocol P {
associatedtype A
}
func generic(value: P) {} // expected-error {{use of protocol 'P' as a type must be written 'any P'}}
// expected-note@-1 {{Replace 'P' with 'any P'}} {{21-21= any P}} Is this close to how the verifier should be written? This is not passing the Let's say I get it to pass verification, but I change the |
|
@taevonlewis Are you fine with passing this over to Saehej? |
Yes, they can take over this issue |
With the
|
Right, there is no actual note emitted on the specified line (and at all), so there is nothing to compare your expectation with, just the fact that it was not fulfilled. |
We want to make updates to this diagnostic I found below. I was thinking to add a new variable
On this line in TypeCheckType the diagnostic is used and passes in the My thought process was to look for something similar that uses the keyword |
A fix-it by itself is not a diagnostic message. It is a text substitution descriptor (a range + a replacement string) that is attached to and emitted with a diagnostic message. Custom fix-it descriptions are implemented by attaching the fix-it to a note rather than the primary warning/error. The fix-it on the screenshot is attached to an error; its description was autogenerated by Xcode. I suggest hardcoding the |
@hborla Do you reckon we should also suggest both options in positions where |
@AnthonyLatsis I won't be able to work on this issue anymore. I noticed you merged changes that streamlined the logic in the syntax checker. Unfortunately, I do not have the time to redo the logic based on your changes. |
No worries, thanks for letting me know. |
The following code is invalid:
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 theany
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 considerany
orsome
, and there should be two notes, each with a fix-it to insertany
orsome
, respectively.The text was updated successfully, but these errors were encountered: