-
Notifications
You must be signed in to change notification settings - Fork 76
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
Conversation
Hi @nreid260! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 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(";") |
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 would have expected this to be after
visit(child)
, no? - 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?
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.
Yes, fixed. Silly cut/paste error from my main workspace.
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 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.
Sounds good. I can't import the PR before the CLA is signed. |
I believe I signed this morning. Perhaps it's still propagating, or Google requires an organization level signature. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Before this, such semicolons caused a crash because OpBuilder noticed they were skipped in the token stream.