diff options
author | 2016-08-04 20:17:28 +0000 | |
---|---|---|
committer | 2016-08-05 08:22:22 +0000 | |
commit | 6aa2f64045d390f4da77d396cd3fcbe1c44a98c1 (patch) | |
tree | d62ee82911dc338185b991ed0e96863e583374f1 /src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java | |
parent | 51cda2dfc44d1fc6a7959c62a8faed637e3c2a36 (diff) |
Fix Environment.Continuation's tracking of global variables
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=129365195
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java b/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java index d5d393702b..3451238e01 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/FunctionTest.java @@ -120,6 +120,18 @@ public class FunctionTest extends EvaluationTestCase { } @Test + public void testFunctionDefLocalVariableReferencedInCallBeforeAssignment() throws Exception { + checkEvalErrorContains("Variable 'a' is referenced before assignment.", + "def dummy(x):", + " pass", + "a = 1", + "def func():", + " dummy(a)", + " a = 2", + "func()\n"); + } + + @Test public void testFunctionDefLocalVariableReferencedAfterAssignment() throws Exception { eval("a = 1", "def func():", |