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

Fix comments for smartPipeline topic-forbidding contexts #11597

Merged
merged 1 commit into from May 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 6 additions & 9 deletions packages/babel-parser/src/parser/statement.js
Expand Up @@ -659,9 +659,7 @@ export default class StatementParser extends ExpressionParser {

clause.body =
// For the smartPipelines plugin: Disable topic references from outer
// contexts within the function body. They are permitted in function
// default-parameter expressions, which are part of the outer context,
// outside of the function body.
// contexts within the catch clause's body.
this.withTopicForbiddingContext(() =>
// Parse the catch clause's body.
this.parseBlock(false, false),
Expand Down Expand Up @@ -718,9 +716,9 @@ export default class StatementParser extends ExpressionParser {

node.body =
// For the smartPipelines plugin:
// Disable topic references from outer contexts within the function body.
// Disable topic references from outer contexts within the with statement's body.
// They are permitted in function default-parameter expressions, which are
// part of the outer context, outside of the function body.
// part of the outer context, outside of the with statement's body.
this.withTopicForbiddingContext(() =>
// Parse the statement body.
this.parseStatement("with"),
Expand Down Expand Up @@ -1074,8 +1072,8 @@ export default class StatementParser extends ExpressionParser {
this.parseFunctionParams(node);

// For the smartPipelines plugin: Disable topic references from outer
// contexts within the function body. They are permitted in test
// expressions, outside of the function body.
// contexts within the function body. They are permitted in function
// default-parameter expressions, outside of the function body.
this.withTopicForbiddingContext(() => {
// Parse the function body.
this.parseFunctionBodyAndFinish(
Expand Down Expand Up @@ -1197,8 +1195,7 @@ export default class StatementParser extends ExpressionParser {
this.expect(tt.braceL);

// For the smartPipelines plugin: Disable topic references from outer
// contexts within the class body. They are permitted in test expressions,
// outside of the class body.
// contexts within the class body.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this shortening is an improvement.

Copy link
Contributor Author

@lazytype lazytype May 22, 2020

Choose a reason for hiding this comment

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

I believe the existing comment was copy-pasted from parseWhileStatement, where the mention of a "test expression" makes sense since while loops have one, i.e.
while (<test_expression>) {
but since class bodies do not, removing mention of "test expression" is removing objectively false information from the comment (which I found to be quite confusing when I first encountered the comment).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, fair.

this.withTopicForbiddingContext(() => {
while (!this.match(tt.braceR)) {
if (this.eat(tt.semi)) {
Expand Down