Skip to content

Conversation

@keith
Copy link
Member

@keith keith commented Dec 3, 2025

If there are assignments above package() calls they could contain
variables used in the package() call. We now check for that case so we
can move it as far up as possible.

Fixes #1420

If there are assignments above package() calls they could contain
variables used in the package() call. We now check for that case so we
can move it as far up as possible.

Fixes bazelbuild#1420
usedSymbols := UsedSymbols(pkg.Call)
for varName := range definedVars {
if usedSymbols[varName] {
return false
Copy link
Member Author

Choose a reason for hiding this comment

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

note it is possible to instead of bailing here move to just below the var that is actually used, but that doesn't seem super important

@AnnaSvalova AnnaSvalova removed the request for review from oreflow December 3, 2025 14:21
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.

buildifier does not move package() to the top in some cases

2 participants