-
Notifications
You must be signed in to change notification settings - Fork 441
Implement a few more diagnostics in SwiftParser #1124
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
@swift-ci Please test |
d080623
to
4fa50f6
Compare
@swift-ci Please test |
@@ -237,8 +237,7 @@ final class GenericDisambiguationTests: XCTestCase { | |||
func testGenericDisambiguation15() { | |||
AssertParse( | |||
""" | |||
// TODO: parse empty <> list | |||
//A<>.c() // e/xpected-error{{xxx}} | |||
A<>.c() |
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 tree does this produce?
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.
Thanks for checking. It parses <>
as an operator. I’ll leave this TODO in for now.
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.
Would be good to keep a TODO here (or did you open a bug?)
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 wonder where I lost that change to keep the TODO. It’s in again now.
@@ -22,10 +22,7 @@ final class HashbangLibraryTests: XCTestCase { | |||
class Foo {} | |||
// Check that we diagnose and skip the hashbang at the beginning of the file | |||
// when compiling in library mode. | |||
""", | |||
diagnostics: [ | |||
// TODO: Old parser expected error on line 1: hashbang line is allowed only in the main file |
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.
No diagnostic... what tree do we produce 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.
We parse the shebang as trivia. I would like to parse it as part of the source file at some point (rdar://98309158) but the current implementation isn’t too bad.
Added a substructure test.
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.
FWIW you don't need all those nil
's any more. Maybe we should update the dump to not add them either 🤔
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.
Thanks, the PR is so old it still required the nil
s when I created it. I removed them.
func testStructNamedAny() { | ||
AssertParse( | ||
""" | ||
struct any {} |
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.
Was the point of this test to check a keyword or to check Any
for anyKeyword
?
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.
Damn, I hate that we have capital any and lowercase any. I also added a test case for capital Any
. It’s behaving correctly as well.
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.
Heh :) All the more reason to merge keywords!
@@ -150,7 +150,7 @@ extension Parser { | |||
introucerHandle: RecoveryConsumptionHandle | |||
) -> T where T: NominalTypeDeclarationTrait { | |||
let (unexpectedBeforeIntroducerKeyword, introducerKeyword) = self.eat(introucerHandle) | |||
let (unexpectedBeforeName, name) = self.expectIdentifier(keywordRecovery: true) | |||
let (unexpectedBeforeName, name) = self.expectIdentifier(allowIdentifierLikeKeywords: false, keywordRecovery: true) |
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.
When we do the keyword merging it would be nice to have sets for all the different "keyword" tokens we can have.
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.
Absolutely!
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.
Hey we can totally do this now :D. But fine not to for 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.
Maybe in a follow-up PR.
4fa50f6
to
fc80b78
Compare
@swift-ci Please test |
fc80b78
to
f5c61fa
Compare
@swift-ci Please test |
f5c61fa
to
922c27a
Compare
@swift-ci Please test |
922c27a
to
8ad44fb
Compare
@swift-ci Please test |
@@ -237,8 +237,7 @@ final class GenericDisambiguationTests: XCTestCase { | |||
func testGenericDisambiguation15() { | |||
AssertParse( | |||
""" | |||
// TODO: parse empty <> list | |||
//A<>.c() // e/xpected-error{{xxx}} | |||
A<>.c() |
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.
Would be good to keep a TODO here (or did you open a bug?)
@@ -150,7 +150,7 @@ extension Parser { | |||
introucerHandle: RecoveryConsumptionHandle | |||
) -> T where T: NominalTypeDeclarationTrait { | |||
let (unexpectedBeforeIntroducerKeyword, introducerKeyword) = self.eat(introucerHandle) | |||
let (unexpectedBeforeName, name) = self.expectIdentifier(keywordRecovery: true) | |||
let (unexpectedBeforeName, name) = self.expectIdentifier(allowIdentifierLikeKeywords: false, keywordRecovery: true) |
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.
Hey we can totally do this now :D. But fine not to for this PR.
@@ -22,10 +22,7 @@ final class HashbangLibraryTests: XCTestCase { | |||
class Foo {} | |||
// Check that we diagnose and skip the hashbang at the beginning of the file | |||
// when compiling in library mode. | |||
""", | |||
diagnostics: [ | |||
// TODO: Old parser expected error on line 1: hashbang line is allowed only in the main file |
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.
FWIW you don't need all those nil
's any more. Maybe we should update the dump to not add them either 🤔
8ad44fb
to
71ef7bf
Compare
@swift-ci Please test |
A few unrelated commits to migrate more diagnostics from the C++ parser to SwiftParser.