Cleaner separatation between Module and Universe variables.
- In the global frame, rename "parent" into "universe" to clarify what it is.
- Function `moduleLookup` now does the right thing. It doesn't check the universe anymore.
This means that we now forbid (with --incompatible_static_name_resolution) this:
a = len("abc")
len = 2
#5827
RELNOTES: None.
PiperOrigin-RevId: 213647873
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
index 810aaa2..3dae2bc 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
@@ -1839,7 +1839,16 @@
@Test
public void testShadowBuiltin() throws Exception {
- // TODO(laurentlb): Forbid this.
+ new SkylarkTest("--incompatible_static_name_resolution=true")
+ .testIfErrorContains(
+ "global variable 'len' is referenced before assignment",
+ "x = len('abc')",
+ "len = 2",
+ "y = x + len");
+ }
+
+ @Test
+ public void testLegacyShadowBuiltin() throws Exception {
new SkylarkTest("--incompatible_static_name_resolution=false")
.setUp("x = len('abc')", "len = 2", "y = x + len")
.testLookup("y", 5);