-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[libSyntax, tests] Preparations for verification of syntax tree on SILGen tests #16174
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
[libSyntax, tests] Preparations for verification of syntax tree on SILGen tests #16174
Conversation
@swift-ci Please smoke test |
27d023b
to
eb42a57
Compare
@swift-ci Please smoke test |
@eeckstein could you take a look at the update of sil gen tests? @ahoppen makes all silgen tests also libSyntax tests by ensuring we have no problem parsing those valid syntax. |
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.
lgtm.
@jckarter: any comments from your side?
@@ -476,7 +476,12 @@ | |||
Child('Modifier', kind='DeclModifier', is_optional=True), | |||
Child('AccessorKind', kind='Token', |
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.
(Not in this PR) This should be ContextualKeywordToken
(when we implement libSyntax-based syntax-coloring)
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'll do that in a follow-up PR.
lib/Parse/ParseDecl.cpp
Outdated
SyntaxParsingContext BlockItemListContext(SyntaxContext, | ||
SyntaxKind::CodeBlockItemList); | ||
SyntaxParsingContext BodyContext(SyntaxContext, SyntaxKind::CodeBlock); | ||
BodyContext.setDiscard(); |
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.
Please don't use setDiscard()
here. Parsing this invalid code:
precedencegroup class {
garbage...
}
loses roundtripness.
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.
Good point. I thought it was only used in delayed function body parsing. Changed it to a TokenList
.
SyntaxKind::IdentifierExpr); | ||
// Consume 'type' | ||
keywordLoc = consumeToken(); | ||
} |
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.
Nice catch!
@@ -6,6 +6,6 @@ enum E<T>: Int { | |||
} | |||
|
|||
// CHECK-LABEL: sil hidden @$S22enum_generic_raw_value1FO | |||
enum F<T: ExpressibleByIntegerLiteral where T: Equatable>: T { | |||
enum F<T: ExpressibleByIntegerLiteral>: T where T: Equatable { |
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.
(Not in this PR) We should consider accepting optional GenericWhereClause
inside GenericParameterClause
. As long as we offer fix-it, it should be treated as well-formed syntax.
(I'm not against fixing SILGen
tests in this PR.)
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 spoke with Argyrios about this and we decided not to support libSyntax parsing of Swift 3. It is being deprecated anyway and we will probably not be able to provide the coverage we will for Swift 4.
prefix operator ~~~ | ||
infix operator <*> | ||
infix operator <**> | ||
infix operator <===> |
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.
(But I don't want to accept {}
for operator decls...) 🤔
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.
What do you mean?
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 wanted to accept where
clause in generic parameter clause, but I did not want to accept deprecated operator
decl syntax.
This will parse the source file into a libSyntax tree and verify that no unknown nodes exist within it
eb42a57
to
569a710
Compare
569a710
to
dc3e43b
Compare
@swift-ci Please smoke test |
@eeckstein SILGen test changes look fine to me. |
These are a couple of minor fixes that will allow libSyntax to parse all the SILGen tests, in particular:
-verify-syntax-tree
frontend flag that will parse the syntax tree and error if any unknown nodes exist within itArray<Int>.[]
)unsafeMutableAddress
){}
))
in one testIn an upcoming PR I will flip the switch to always verify the syntax tree generated when parsing the SILGen tests. That way we should have a smoke test making sure that no new syntax gets introduced without libSyntax being able to parse it.