Roll forward fix of global var shadow detection
RELNOTES[INC]: Skylark: It is an error to shadow a global variable with a local variable after the global has already been accessed in the function.
--
MOS_MIGRATED_REVID=130014492
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
index 2aab881..ec504a0 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
@@ -222,12 +222,14 @@
FuncallExpression caller,
Frame lexicalFrame,
Frame globalFrame,
+ Set<String> knownGlobalVariables,
boolean isSkylark) {
this.continuation = continuation;
this.function = function;
this.caller = caller;
this.lexicalFrame = lexicalFrame;
this.globalFrame = globalFrame;
+ this.knownGlobalVariables = knownGlobalVariables;
this.isSkylark = isSkylark;
}
}
@@ -369,7 +371,8 @@
*/
void enterScope(BaseFunction function, FuncallExpression caller, Frame globals) {
continuation =
- new Continuation(continuation, function, caller, lexicalFrame, globalFrame, isSkylark);
+ new Continuation(continuation, function, caller, lexicalFrame, globalFrame,
+ knownGlobalVariables, isSkylark);
lexicalFrame = new Frame(mutability(), null);
globalFrame = globals;
knownGlobalVariables = new HashSet<>();