-
Notifications
You must be signed in to change notification settings - Fork 439
Add diagnostic for canImport
expression
#1574
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
canImport
expressioncanImport
expression
There are 4 TODOs left in #if canImport(A, _version: 2.2.2.2.2) // TODO: Old parser expected error on line 1: trailing components of version '2.2.2.2' are ignored
#if canImport(A, _version: >=2.2) // TODO: Old parser expected error on line 1: cannot parse module version '>=2.2' I think we can leave these diagnostics to the type check stage, since 1) Leaving an |
e00ef9f
to
a0b4326
Compare
74cd42f
to
72ed377
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.
Thank you, that’s much cleaner. Also I didn’t realize we already had forDirective
everywhere. Using that was a good idea!
72ed377
to
8d538b9
Compare
canImport
expressioncanImport
expression
let a = 1 | ||
#endif | ||
"""#, | ||
diagnostics: [ | ||
// TODO: Old parser expected error on line 1: _version argument cannot be empty | ||
DiagnosticSpec(message: "cannot parse version code '\"\"'") |
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.
Where is the code
coming from here?
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.
I think the code
here is because I used shortSingleLineContentDescription
for the node, already removed it.
b3f7028
to
c543645
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.
Very nice. I’ve got a few minor comments regarding documentation, otherwise this looks good to me. 👍🏽
I've updated the documentation according to your suggestion.😀 |
@swift-ci please test |
The test failure is unrelated to your changes @StevenWong12. The status bot is also failing with the same error. I’ll re-trigger CI once the status bot is passing. |
@swift-ci Please test |
be45c0e
to
5a350d1
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
Looks like the PR conflicted with another one. Could rebase and resolve the conflicts? |
Add `forDirective` parameter for `parsePrimaryExpression` to branch into directive expression parsing for `canImport`, `compiler` and `swift` keywords Refactor version tuple parse and `VersionTuple` node and add diagnostics for it Add assertion for the name of `Child` to make its first character uppercase
Refactor some codes to make them cleaner
Rerun CodeGeneration
Head branch was pushed to by a user without write access
5a350d1
to
f372c85
Compare
I've got the conflicts resolved. |
@swift-ci please test |
kind: .token(choices: [.token(tokenKind: "CommaToken")]), | ||
isOptional: true | ||
), | ||
Child( |
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.
Rather than have a string of optional components, can we split the version information into its own syntax element and make that optional?
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.
That makes sense to me. I've extracted the optional part of canImport
to a separate node.
@swift-ci Please test |
@swift-ci Please test Windows |
@swift-ci Please test Windows |
Fixes part of #1373
This PR should solve all the TODOs in
testIfconfigExpr.swift
.