Skylark: Allow variable reassignment to change the type of a variable.
--
MOS_MIGRATED_REVID=96211360
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 3dcbb9d4..cc0e4aa 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
@@ -469,6 +469,17 @@
}
@Test
+ public void testReassignment() throws Exception {
+ eval("def foo(x=None):",
+ " x = 1",
+ " x = [1, 2]",
+ " x = 'str'",
+ " return x",
+ "s = foo()");
+ assertThat(lookup("s")).isEqualTo("str");
+ }
+
+ @Test
public void testJavaCalls() throws Exception {
update("mock", new Mock());
eval("b = mock.is_empty('a')");