-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Use backticks instead of single quotes in diagnostics #26499
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
Conversation
@@ -4534,7 +4534,7 @@ WARNING(property_wrapper_wrapperValue,none, | |||
"'projectedValue'; use of 'wrapperValue' is deprecated", ()) | |||
WARNING(property_wrapper_init_initialValue,none, | |||
"property wrapper's `init(initialValue:)` should be renamed " | |||
"to 'init(wrappedValue:)'; use of 'init(initialValue:)' is deprecated", | |||
"to `init(wrappedValue:)`; use of `init(initialValue:)` is deprecated", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great example of the inconsistency: the same method was quoted with both backticks and single quotes within the same diagnostic.
FWIW, the diagnostics style document uses single quotes, and should be updated if a style change is made. Personally, I prefer single quotes because I think they look a little nicer plain-text output, but I agree that either way the usage should be consistent! I'll let others weigh in on the backticks vs. quotes debate. |
In the diagnostics, single quotes are used around anything in code voice, which includes keywords. Using backticks, while consistent with Markdown, could actually be confusing for users because enclosing a keyword in backticks has a different meaning in Swift—causing it not to be parsed as a keyword at all. Consider the warning about |
I think the most important thing is to be consistent. But I find it unlikely that a user will be confused by |
They can be equally confused by both, but one of these is potentially syntactically valid Swift with a meaning that’s unintended, and the other is syntactically invalid and diagnosed at compile time. |
I err on the side of being consistent the opposite direction. The diagnostics style is mostly inherited from Clang, and Clang chooses single quotes to wrap identifiers. Could you please rebase this pull request and use single quotes instead? |
I think Clang sets a low bar for diagnostics (despite being vastly superior to GCC in this regard). But I agree that consistency is most important. I'll try to find time to redo this. |
Closing in favor of changing backticks to single quotes in #29895. |
Looking through the diagnostics, I noticed some inconsistencies around whether
'
s or`
s were used in diagnostics. AFAICT there wasn't a pattern to when one was used over the other.This is an initial PR to convert to backticks. If accepted, I'll follow up with more PRs to convert to backticks. If rejected, I'd be happy to open a PR to remove backticks from existing diagnostics.
I prefer backticks here because: