Add 'did you mean' suggestion when accessing an undefined variable.

--
PiperOrigin-RevId: 143373605
MOS_MIGRATED_REVID=143373605
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
index cde97c1..ae6b8fb 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
@@ -518,7 +518,7 @@
 
     new SkylarkTest()
         .testIfErrorContains(
-            "ERROR 1:1: function 'join' does not exist", "join(' ', [ 'a', 'b', 'c' ])");
+            "ERROR 1:1: name 'join' is not defined", "join(' ', [ 'a', 'b', 'c' ])");
 
     new BothModesTest().testStatement("' '.join([ 'a', 'b', 'c' ])", "a b c");
   }
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
index 8cd35f2..c527fd2 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
@@ -1204,7 +1204,7 @@
   public void testLoadNotAtTopLevel() throws Exception {
     setFailFast(false);
     parseFileForSkylark("if 1: load(8)\n");
-    assertContainsError("function 'load' does not exist");
+    assertContainsError("name 'load' is not defined");
   }
 
   @Test
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 f6493ba..38874b8 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
@@ -1044,6 +1044,15 @@
   }
 
   @Test
+  public void testTypo() throws Exception {
+    new SkylarkTest()
+        .testIfErrorContains(
+            "name 'my_variable' is not defined (did you mean 'myVariable'?)",
+            "myVariable = 2",
+            "x = my_variable + 1");
+  }
+
+  @Test
   public void testNoneTrueFalseInSkylark() throws Exception {
     new SkylarkTest().setUp("a = None",
       "b = True",
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java
index b420ffd..2e4ae53 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java
@@ -103,7 +103,7 @@
 
   @Test
   public void testFunctionDoesNotExist() {
-    checkError("function 'foo' does not exist", "def bar(): a = foo() + 'a'");
+    checkError("name 'foo' is not defined", "def bar(): a = foo() + 'a'");
   }
 
   @Test