-
Notifications
You must be signed in to change notification settings - Fork 441
Allow leading dot syntax for StaticParserError #951
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
5c4f14f
to
90529e8
Compare
:( wonder what swift version CI is using |
0847c30
to
227e4e4
Compare
Looks like the CI is using Swift 5.5, which should be fine as it should have SE-0299, but it seems the 5.5 constraint system is barfing when a closure is involved (works on 5.6 though). Adding a generic parameter to |
227e4e4
to
be6661f
Compare
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.
Neat idea 🤩 I’ve got a couple of additional suggestion/ideas:
- Could you add a test case that checks the diagnostic ID for one
StaticParserError
? I would like to see how the diagnostic ID looks like (basically making sure it contains no parentheses) - I find it harder to find diagnostic messages in the new extension but I think that’s resolved by formatting the diagnostic messages as single lines, e.g.
public static var allStatmentsInSwitchMustBeCoveredByCase: Self { .init("all statements inside a switch must be covered by a 'case' or 'default' label") }
- I think we can do the same for
StaticParserFixIt
.
We already have one :)
Hmm, I definitely prefer the current formatting. Putting them on a single line means that each diagnostic message starts at a different column (depending on how long the var name is), which make it hard to read IMO. It also makes it extra hard for people with smaller screens, e.g:
👍 |
be6661f
to
67e75ff
Compare
Bleh, the 5.5 compiler really seems to struggle with these:
going to add back the |
5d6201f
to
1d11fc6
Compare
1d11fc6
to
14a014b
Compare
Convert StaticParserError into a struct, and define the diagnostics in a `DiagnosticMessage where Self == StaticParserError` extension. This allows us to use leading dot syntax to pass a StaticParserError anywhere a DiagnosticMessage is expected. To compute the diagnostic ID, we can (ab)use `#function` to pick up the name of the property.
Following a similar pattern to StaticParserError, convert StaticParserFixIt into a struct with static members in a constrained protocol extension.
14a014b
to
d117cd1
Compare
@swift-ci please test |
Convert StaticParserError into a struct, and define the diagnostics in a
DiagnosticMessage where Self == StaticParserError
extension. This allows us to use leading dot syntax to pass a StaticParserError anywhere a DiagnosticMessage is expected. Also, do the same for StaticParserFixIt.To compute the diagnostic ID, we can (ab)use
#function
to pick up the name of the property