diff --git a/site/docs/skylark/backward-compatibility.md b/site/docs/skylark/backward-compatibility.md index 3e531fd8d540e6..b60d9ce86a483c 100644 --- a/site/docs/skylark/backward-compatibility.md +++ b/site/docs/skylark/backward-compatibility.md @@ -275,7 +275,7 @@ a `list`. Because of this repetitions using `*` operator are no longer 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 c1c91a854eba06..444663d6cb2f94 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 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable @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 5af8f655af92c1..59da160c18169e 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 @@ public static Builder builderWithDefaults() { .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 afd71467a4bf08..5469e77239cfb3 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 @@ public void testHash() throws Exception { @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 @@ public void testRangeType() throws Exception { */ 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 @@ private void runRangeIsListAssertions(String range3expr) throws Exception { .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 @@ private void runRangeIsListAssertions(String range3expr) throws Exception { "[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 75d9be441bc70d..8893e21dcbc0cf 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 8a66410a0469f6..f6dafb1b924217 100644 --- a/tools/android/android_sdk_repository_template.bzl +++ b/tools/android/android_sdk_repository_template.bzl @@ -292,7 +292,7 @@ def create_system_images_filegroups(system_image_dirs): 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 = [