commit | d59ab90b7ac7fb0011782859276c29230f1036d5 | [log] [tgz] |
---|---|---|
author | Tim Malmström <oreflow@google.com> | Tue Jun 24 13:38:49 2025 +0200 |
committer | Tim Malmström <oreflow@google.com> | Tue Jun 24 13:55:57 2025 +0200 |
tree | f2b1347f0628d126a5c461607c8ab6cffdbc3dca | |
parent | a2a20c9c1c7cb85905a0fc5aad9ec02370cfdb1f [diff] |
Bugfix false positive for "unused" variable for nested `def`s When detecting whether symbols are used or not, variables referenced as argument defaults of the inner def would count as "use" in the inner scope, and hence falsely trigger "unused" warning. Example: ``` def outer_def(name, foo = "foo"): def inner_def(foo = foo): print(foo) # buildifier: disable=print inner_def() ``` Unused variable check for the above function would 1. Check outer_def for variable usage 2. Recursively check inner_def for variable usage - Detect that `foo` is used - Omit `foo` from returned usedSymbolsFromOuterScope since `foo` is a local variable 3. Receive no "usedSymbol" for `foo` 4. Output "unused-variable" warning If there are RHS idents in a def statement, these idents are always from an outer scope, so these can check the later inner-scope definedSymbols check.
This repository contains developer tools for working with Google's bazel
buildtool.
See instructions in each tool's directory.