Skip to content

Bug fix. Correctly identify expressions using &=, ^=, >>=, and <<= as assignment statements when parsing BUILD files.#1357

Merged
vladmos merged 2 commits intobazelbuild:mainfrom
pdoyle12:master
Apr 27, 2025
Merged

Bug fix. Correctly identify expressions using &=, ^=, >>=, and <<= as assignment statements when parsing BUILD files.#1357
vladmos merged 2 commits intobazelbuild:mainfrom
pdoyle12:master

Conversation

@pdoyle12
Copy link
Contributor

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.

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.
Copy link
Member

@vladmos vladmos left a comment

Choose a reason for hiding this comment

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

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.
@pdoyle12
Copy link
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.

@vladmos
Copy link
Member

vladmos commented Apr 27, 2025

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).

@vladmos vladmos merged commit d9ed52a into bazelbuild:main Apr 27, 2025
2 checks passed
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.
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