Skip to content
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

Account for semicolons on top-level statements. #275

Closed
wants to merge 1 commit into from

Conversation

nreid260
Copy link
Contributor

@nreid260 nreid260 commented Feb 8, 2022

Before this, such semicolons caused a crash because OpBuilder noticed they were skipped in the token stream.

@facebook-github-bot
Copy link
Contributor

Hi @nreid260!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@@ -2296,6 +2296,7 @@ class KotlinInputAstVisitor(
lastChildHadBlankLineBefore = childGetsBlankLineBefore
first = false
}
builder.guessToken(";")
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I would have expected this to be after visit(child), no?
  2. We had a nasty bug in the past where guessToken would swallow a token from a completely unrelated node in the AST, so I'm weary of it. I don't remember the specifics unfortunately. Any chance you can poke around the expression object and maybe find a boolean indicating whether there's a trailing semicolon?

Copy link
Contributor Author

@nreid260 nreid260 Feb 8, 2022

Choose a reason for hiding this comment

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

Yes, fixed. Silly cut/paste error from my main workspace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any such boolean on KtExpression. Perhaps we could check for it in every visit method, but that seems pretty error prone.

I'm also not sure how this could manifest such a bug. These semicolons are all immediately after a statement-expression. The only way we could accidentally consume one is if a following statement had a leading semicolon, which was semantically important. I don't think is possible in the grammar.

Before this, such semicolons caused a crash because OpBuilder noticed they were skipped in the token stream.
@cgrushko
Copy link
Contributor

cgrushko commented Feb 8, 2022

Sounds good. I can't import the PR before the CLA is signed.

@nreid260
Copy link
Contributor Author

nreid260 commented Feb 8, 2022

I believe I signed this morning. Perhaps it's still propagating, or Google requires an organization level signature.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 8, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@nreid260 nreid260 deleted the nreid260 branch February 9, 2022 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants