Skip to content

Emit diagnostics for missing nodes #657

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

Closed

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Aug 30, 2022

Depends on #656


Previously, we weren’t emitting any errors for the missing layout nodes (RawMissingExprSyntax etc.)

@ahoppen ahoppen requested review from rintaro and bnbarham August 30, 2022 14:07
@ahoppen
Copy link
Member Author

ahoppen commented Aug 31, 2022

swiftlang/swift#60847

@swift-ci Please test

message += " after '\(previousToken.text)'"
}
if let parent = missingNode.parent, let parentTypeName = parent.nodeTypeNameForDiagnostics {
if parentTypeName != "source file" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not check the type rather than string?

@@ -97,7 +97,8 @@ final class DeclarationTests: XCTestCase {
AssertParse(
"_ = foo/* */?.description#^DIAG^#",
diagnostics: [
DiagnosticSpec(message: "Expected ':' after '? ...' in ternary expression")
DiagnosticSpec(message: "Expected ':' after '? ...' in ternary expression"),
DiagnosticSpec(message: "Expected expression after ':'"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I mentioned this in some other PR, but multiple diagnostics at the same location seem odd to me. Could we filter all but the first at the same location out?

@@ -439,7 +443,12 @@ final class DeclarationTests: XCTestCase {

func testExtraneousRightBraceRecovery() {
AssertParse(
"class ABC { let def = ghi(jkl: mno) } #^DIAG^#}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this change anything, or were you just making the test case easier to see?

Comment on lines +15 to +17
AssertParse(
"a ? b :"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this have the "expected expression after ':'" diagnostic?

Comment on lines 158 to 159
DiagnosticSpec(message: "Expected expression after ':' in dictionary"),
DiagnosticSpec(message: "Expected ']' to end dictionary"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. FWIW the current diagnostic is a missing dictionary value (expected value in dictionary literal), but I think it's fine not to special case it.

There's obviously quite a few of these cases so I won't mention any others 😅

@ahoppen
Copy link
Member Author

ahoppen commented Sep 7, 2022

Closing this because after some discussion we decided that #656 was not the right approach.

Instead, this is part of my recovery backlog in #718.

I’ll try to remember and address the review comments when creating the PR that contains this change from the backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants