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

Preserve loads if they're different #1137

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

illicitonion
Copy link
Contributor

WORKSPACE files currently allow shadowing loads (see bazelbuild/bazel#17480), i.e. the following is valid:

load("//:one.bzl", "fn")

fn()

load("//:two.bzl", "fn")

fn()

Currently buildozer removes the second load because the symbol was already loaded. This is incorrect - removing the second load changes the behaviour of this file.

Instead, only delete a load of the last time it was loaded was from the same place.

WORKSPACE files currently allow shadowing loads (see
bazelbuild/bazel#17480), i.e. the following is
valid:

```starlark
load("//:one.bzl", "fn")

fn()

load("//:two.bzl", "fn")

fn()
```

Currently buildozer removes the second load because the symbol was
already loaded. This is incorrect - removing the second load changes the
behaviour of this file.

Instead, only delete a load of the last time it was loaded was from the
same place.
@illicitonion
Copy link
Contributor Author

@vladmos could I bother you for a review? The PR is pretty small and simple :) Thanks!

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.

Thanks, sorry for the delay!

@vladmos vladmos merged commit a6ca93f into bazelbuild:master Mar 2, 2023
apattidb pushed a commit to databricks/buildtools that referenced this pull request May 10, 2024
WORKSPACE files currently allow shadowing loads (see
bazelbuild/bazel#17480), i.e. the following is
valid:

```starlark
load("//:one.bzl", "fn")

fn()

load("//:two.bzl", "fn")

fn()
```

Currently buildozer removes the second load because the symbol was
already loaded. This is incorrect - removing the second load changes the
behaviour of this file.

Instead, only delete a load of the last time it was loaded was from the
same place.
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