Switch the default value of --incompatible_range_type

#5264

RELNOTES: `range()` function now returns a lazy value (`--incompatible_range_type` is now set by default).
PiperOrigin-RevId: 218920956
diff --git a/site/docs/skylark/backward-compatibility.md b/site/docs/skylark/backward-compatibility.md
index 3e531fd..b60d9ce 100644
--- a/site/docs/skylark/backward-compatibility.md
+++ b/site/docs/skylark/backward-compatibility.md
@@ -275,7 +275,7 @@
 supported and `range` slices are also lazy `range` instances.
 
 *   Flag: `--incompatible_range_type`
-*   Default: `false`
+*   Default: `true`
 *   Tracking issue: [#5264](https://github.com/bazelbuild/bazel/issues/5264)
 
 
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
index c1c91a8..444663d 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
@@ -437,7 +437,7 @@
 
   @Option(
       name = "incompatible_range_type",
-      defaultValue = "false",
+      defaultValue = "true",
       documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS,
       effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
       metadataTags = {
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
index 5af8f65..59da160 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
@@ -221,7 +221,7 @@
           .incompatibleNoTargetOutputGroup(false)
           .incompatibleNoTransitiveLoads(false)
           .incompatiblePackageNameIsAFunction(false)
-          .incompatibleRangeType(false)
+          .incompatibleRangeType(true)
           .incompatibleRemoveNativeGitRepository(true)
           .incompatibleRemoveNativeHttpArchive(true)
           .incompatibleStaticNameResolution(false)
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 afd7146..5469e77 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
@@ -471,7 +471,7 @@
 
   @Test
   public void testRange() throws Exception {
-    new BothModesTest()
+    new BothModesTest("--incompatible_range_type=false")
         .testStatement("str(range(5))", "[0, 1, 2, 3, 4]")
         .testStatement("str(range(0))", "[]")
         .testStatement("str(range(1))", "[0]")
@@ -564,14 +564,14 @@
    */
   private void runRangeIsListAssertions(String range3expr) throws Exception {
     // Check stringifications.
-    new BothModesTest()
+    new BothModesTest("--incompatible_range_type=false")
         .setUp("a = " + range3expr)
         .testStatement("str(a)", "[0, 1, 2]")
         .testStatement("repr(a)", "[0, 1, 2]")
         .testStatement("type(a)", "list");
 
     // Check comparisons.
-    new BothModesTest()
+    new BothModesTest("--incompatible_range_type=false")
         .setUp("a = " + range3expr)
         .setUp("b = range(0, 3, 1)")
         .setUp("c = range(1, 4)")
@@ -587,10 +587,10 @@
         .testIfErrorContains("Cannot compare list with tuple", "a < T");
 
     // Check mutations.
-    new BothModesTest()
+    new BothModesTest("--incompatible_range_type=false")
         .setUp("a = " + range3expr)
         .testStatement("a.append(3); str(a)", "[0, 1, 2, 3]");
-    new SkylarkTest()
+    new SkylarkTest("--incompatible_range_type=false")
         .testStatement(
             "def f():\n"
             + "  a = " + range3expr + "\n"
@@ -601,7 +601,7 @@
             "[0, 1, 2, 3]");
 
     // Check concatenations.
-    new BothModesTest()
+    new BothModesTest("--incompatible_range_type=false")
         .setUp("a = " + range3expr)
         .setUp("b = range(3, 4)")
         .setUp("L = [3]")
diff --git a/src/test/skylark/testdata/range.sky b/src/test/skylark/testdata/range.sky
index 75d9be4..8893e21 100644
--- a/src/test/skylark/testdata/range.sky
+++ b/src/test/skylark/testdata/range.sky
@@ -1,17 +1,17 @@
-assert_eq(range(5), [0, 1, 2, 3, 4])
-assert_eq(range(0), [])
-assert_eq(range(1), [0])
-assert_eq(range(-2), [])
-assert_eq(range(-3, 2), [-3, -2, -1, 0, 1])
-assert_eq(range(3, 2), [])
-assert_eq(range(3, 3), [])
-assert_eq(range(3, 4), [3])
-assert_eq(range(3, 5), [3, 4])
-assert_eq(range(-3, 5, 2), [-3, -1, 1, 3])
-assert_eq(range(-3, 6, 2), [-3, -1, 1, 3, 5])
-assert_eq(range(5, 0, -1), [5, 4, 3, 2, 1])
-assert_eq(range(5, 0, -10), [5])
-assert_eq(range(0, -3, -2), [0, -2])
+assert_eq(list(range(5)), [0, 1, 2, 3, 4])
+assert_eq(list(range(0)), [])
+assert_eq(list(range(1)), [0])
+assert_eq(list(range(-2)), [])
+assert_eq(list(range(-3, 2)), [-3, -2, -1, 0, 1])
+assert_eq(list(range(3, 2)), [])
+assert_eq(list(range(3, 3)), [])
+assert_eq(list(range(3, 4)), [3])
+assert_eq(list(range(3, 5)), [3, 4])
+assert_eq(list(range(-3, 5, 2)), [-3, -1, 1, 3])
+assert_eq(list(range(-3, 6, 2)), [-3, -1, 1, 3, 5])
+assert_eq(list(range(5, 0, -1)), [5, 4, 3, 2, 1])
+assert_eq(list(range(5, 0, -10)), [5])
+assert_eq(list(range(0, -3, -2)), [0, -2])
 
 ---
 range(2, 3, 0) ### step cannot be 0
diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl
index 8a66410..f6dafb1 100644
--- a/tools/android/android_sdk_repository_template.bzl
+++ b/tools/android/android_sdk_repository_template.bzl
@@ -292,7 +292,7 @@
     system_images = [
         (tag, str(api), arch)
         for tag in ["android", "google"]
-        for api in [10] + range(15, 20) + range(21, 29)
+        for api in [10] + list(range(15, 20)) + list(range(21, 29))
         for arch in ("x86", "arm")
     ]
     tv_images = [