Proper error messages when built-in rule attributes are overridden #1811

--
MOS_MIGRATED_REVID=135241715
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
index 03590c7..2367da2 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
@@ -97,13 +97,28 @@
       Assert.fail("Expected error '"
           + "There is already a built-in attribute 'tags' which cannot be overridden"
           + "' but got no error");
-    } catch (IllegalArgumentException | EvalException e) {
+    } catch (EvalException e) {
       assertThat(e).hasMessage(
           "There is already a built-in attribute 'tags' which cannot be overridden");
     }
   }
 
   @Test
+  public void testCannotOverrideBuiltInAttributeName() throws Exception {
+    ev.setFailFast(true);
+    try {
+      evalAndExport(
+          "def impl(ctx): return", "r = rule(impl, attrs = {'name': attr.string()})");
+      Assert.fail("Expected error '"
+          + "There is already a built-in attribute 'name' which cannot be overridden"
+          + "' but got no error");
+    } catch (EvalException e) {
+      assertThat(e).hasMessage(
+          "There is already a built-in attribute 'name' which cannot be overridden");
+    }
+  }
+
+  @Test
   public void testImplicitArgsAttribute() throws Exception {
     evalAndExport(
         "def _impl(ctx):",