Bug fix. Correctly identify expressions using &=, ^=, >>=, and <<= as assignment statements when parsing BUILD files.#1357
Merged
vladmos merged 2 commits intobazelbuild:mainfrom Apr 27, 2025
Conversation
Correctly include &=, ^=, >>=, <<= as assignment statements when parsing BUILD files. The Starlark grammar reference (https://github.com/bazelbuild/starlark/blob/master/spec.md#grammar-reference) identifies all of these as assignment statements, but the parser doesn't include them in the list, probably an old oversight. This fixes issue bazelbuild#1330.
vladmos
approved these changes
Apr 27, 2025
Member
vladmos
left a comment
There was a problem hiding this comment.
Could you please add some basic tests (to build/testdata/052.in/golden for the formatter and to warn/warn_control_flow_test.go for the issue mentioned in the linked bug)?
This change adds no-effect tests for &=, ^=, >>=, and <<= to ensure they are recognized as having an effect.
Contributor
Author
|
I've added tests in the warn_control_flow_test.go file. (I did validate that these correctly catch the specific problem mentioned in the linked bug.) It turns out there already are formatting tests for these cases in the golden file (052.in); if you'd like a more specific test as well, let me know. |
Member
|
You're right, I thought only some of the assignment expressions were mentioned there (as binary expressions, but there's no difference for the formatter). |
oreflow
pushed a commit
that referenced
this pull request
May 5, 2025
… assignment statements when parsing BUILD files. (#1357) * Add files via upload Correctly include &=, ^=, >>=, <<= as assignment statements when parsing BUILD files. The Starlark grammar reference (https://github.com/bazelbuild/starlark/blob/master/spec.md#grammar-reference) identifies all of these as assignment statements, but the parser doesn't include them in the list, probably an old oversight. This fixes issue #1330. * Update warn_control_flow_test This change adds no-effect tests for &=, ^=, >>=, and <<= to ensure they are recognized as having an effect.
oreflow
pushed a commit
that referenced
this pull request
May 5, 2025
… assignment statements when parsing BUILD files. (#1357) * Add files via upload Correctly include &=, ^=, >>=, <<= as assignment statements when parsing BUILD files. The Starlark grammar reference (https://github.com/bazelbuild/starlark/blob/master/spec.md#grammar-reference) identifies all of these as assignment statements, but the parser doesn't include them in the list, probably an old oversight. This fixes issue #1330. * Update warn_control_flow_test This change adds no-effect tests for &=, ^=, >>=, and <<= to ensure they are recognized as having an effect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Correctly identify expressions using &=, ^=, >>=, <<= as assignment statements when parsing BUILD files.
The Starlark grammar reference (https://github.com/bazelbuild/starlark/blob/master/spec.md#grammar-reference) identifies expressions using all of these as assignment statements, but the parser doesn't include them in the list, probably an old oversight.
This fixes issue #1330.