Remove old flags.
RELNOTES:
Removed flags `--incompatible_checked_arithmetic`, `--incompatible_dict_literal_has_no_duplicates`, `--incompatible_disallow_keyword_only_args`, and ` --incompatible_comprehension_variables_do_not_leak`.
PiperOrigin-RevId: 185977740
diff --git a/site/docs/skylark/backward-compatibility.md b/site/docs/skylark/backward-compatibility.md
index c5fc2f1..6c0ab4f 100644
--- a/site/docs/skylark/backward-compatibility.md
+++ b/site/docs/skylark/backward-compatibility.md
@@ -31,18 +31,14 @@
guarded behind flags in the current release:
* [Set constructor](#set-constructor)
-* [Keyword-only arguments](#keyword-only-arguments)
* [Dictionary concatenation](#dictionary-concatenation)
* [Load must appear at top of file](#load-must-appear-at-top-of-file)
* [Load argument is a label](#load-argument-is-a-label)
* [Top level `if` statements](#top-level-if-statements)
-* [Comprehensions variables](#comprehensions-variables)
* [Depset is no longer iterable](#depset-is-no-longer-iterable)
* [Depset union](#depset-union)
* [String is no longer iterable](#string-is-no-longer-iterable)
-* [Dictionary literal has no duplicates](#dictionary-literal-has-no-duplicates)
* [New actions API](#new-actions-api)
-* [Checked arithmetic](#checked-arithmetic)
* [Glob tracking](#glob-tracking)
* [Print statements](#print-statements)
@@ -63,30 +59,6 @@
* Default: `true`
-### Keyword-only arguments
-
-Keyword-only parameters are parameters that can be called only using their name.
-
-``` python
-def foo(arg1, *, arg2): pass
-
-foo(3, arg2=3)
-```
-
-``` python
-def bar(arg1, *rest, arg2): pass
-
-bar(3, arg2=3)
-```
-
-In both examples, `arg2` must be named at the call site. To preserve syntactic
-compatibility with Python 2, we are removing this feature (which we have never
-documented).
-
-* Flag: `--incompatible_disallow_keyword_only_args`
-* Default: `true`
-
-
### Dictionary concatenation
We are removing the `+` operator on dictionaries. This includes the `+=` form
@@ -133,43 +105,6 @@
* Default: `true`
-### Comprehensions variables
-
-This change makes list and dict comprehensions follow Python 3's semantics
-instead of Python 2's. That is, comprehensions have their own local scopes, and
-variables bound by comprehensions are not accessible in the outer scope.
-
-As a temporary measure to help detect breakage, this change also causes
-variables defined in the immediate outer scope to become inaccessible if they
-are shadowed by any variables in a comprehension. This disallows any uses of the
-variable's name where its meaning would differ under the Python 2 and Python 3
-semantics. Variables above the immediate outer scope are not affected.
-
-``` python
-def fct():
- x = 10
- y = [x for x in range(3)]
- return x
-```
-
-The meaning of this program depends on the flag:
-
- * Under Skylark without this flag: `x` is 10 before the
- comprehension and 2 afterwards. (2 is the last value assigned to `x` while
- evaluating the comprehension.)
-
- * Under Skylark with this flag: `x` becomes inaccessible after the
- comprehension, so that `return x` is an error. If we moved the `x = 10` to
- above the function, so that `x` became a global variable, then no error would
- be raised, and the returned number would be 10.
-
-In other words, please do not refer to a loop variable outside the list or dict
-comprehension.
-
-* Flag: `--incompatible_comprehension_variables_do_not_leak`
-* Default: `true`
-
-
### Depset is no longer iterable
When the flag is set to true, `depset` objects are not treated as iterable. If
@@ -247,26 +182,6 @@
* Default: `false`
-### Dictionary literal has no duplicates
-
-When the flag is set to true, duplicated keys are not allowed in the dictionary
-literal syntax.
-
-``` python
-{"a": 2, "b": 3, "a": 4} # error
-```
-
-When the flag is false, the last value overrides the previous value (so the
-example above is equivalent to `{"a": 4, "b": 3}`. This behavior has been a
-source of bugs, which is why we are going to forbid it.
-
-If you really want to override a value, use a separate statement:
-`mydict["a"] = 4`.
-
-* Flag: `--incompatible_dict_literal_has_no_duplicates`
-* Default: `true`
-
-
### New actions API
This change removes the old methods for registering actions within rules, and
@@ -288,15 +203,6 @@
* Default: `false`
-### Checked arithmetic
-
-When set, arithmetic operations (`+`, `-`, `*`) will fail in case of overflow.
-All integers are stored using signed 32 bits.
-
-* Flag: `--incompatible_checked_arithmetic`
-* Default: `true`
-
-
### Glob tracking
When set, glob tracking is disabled. This is a legacy feature that we expect has
diff --git a/site/docs/skylark/language.md b/site/docs/skylark/language.md
index e4e1512..7142540 100644
--- a/site/docs/skylark/language.md
+++ b/site/docs/skylark/language.md
@@ -138,6 +138,10 @@
* Dictionary literals cannot have duplicated keys. For example, this is an
error: `{"a": 4, "b": 7, "a": 1}`.
+* Variable of a comprehension may not be used after the comprehension. This is
+ stricter than Python 2 and Python 3, which have different behavior (shadowing
+ vs reassignment).
+
* Strings are represented with double-quotes (e.g. when you
call [repr](lib/globals.html#repr)).
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsCodec.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsCodec.java
index 249bc91..fde47f5 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsCodec.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsCodec.java
@@ -44,14 +44,10 @@
throws SerializationException, IOException {
// <== Add new options here in alphabetic order ==>
codedOut.writeBoolNoTag(semantics.incompatibleBzlDisallowLoadAfterStatement());
- codedOut.writeBoolNoTag(semantics.incompatibleCheckedArithmetic());
- codedOut.writeBoolNoTag(semantics.incompatibleComprehensionVariablesDoNotLeak());
codedOut.writeBoolNoTag(semantics.incompatibleDepsetIsNotIterable());
codedOut.writeBoolNoTag(semantics.incompatibleDepsetUnion());
- codedOut.writeBoolNoTag(semantics.incompatibleDictLiteralHasNoDuplicates());
codedOut.writeBoolNoTag(semantics.incompatibleDisableGlobTracking());
codedOut.writeBoolNoTag(semantics.incompatibleDisallowDictPlus());
- codedOut.writeBoolNoTag(semantics.incompatibleDisallowKeywordOnlyArgs());
codedOut.writeBoolNoTag(semantics.incompatibleDisallowToplevelIfStatement());
codedOut.writeBoolNoTag(semantics.incompatibleDisallowUncalledSetConstructor());
codedOut.writeBoolNoTag(semantics.incompatibleLoadArgumentIsLabel());
@@ -68,14 +64,10 @@
// <== Add new options here in alphabetic order ==>
builder.incompatibleBzlDisallowLoadAfterStatement(codedIn.readBool());
- builder.incompatibleCheckedArithmetic(codedIn.readBool());
- builder.incompatibleComprehensionVariablesDoNotLeak(codedIn.readBool());
builder.incompatibleDepsetIsNotIterable(codedIn.readBool());
builder.incompatibleDepsetUnion(codedIn.readBool());
- builder.incompatibleDictLiteralHasNoDuplicates(codedIn.readBool());
builder.incompatibleDisableGlobTracking(codedIn.readBool());
builder.incompatibleDisallowDictPlus(codedIn.readBool());
- builder.incompatibleDisallowKeywordOnlyArgs(codedIn.readBool());
builder.incompatibleDisallowToplevelIfStatement(codedIn.readBool());
builder.incompatibleDisallowUncalledSetConstructor(codedIn.readBool());
builder.incompatibleLoadArgumentIsLabel(codedIn.readBool());
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 afbdcd7..36dfbe0 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
@@ -73,32 +73,6 @@
public boolean incompatibleBzlDisallowLoadAfterStatement;
@Option(
- name = "incompatible_checked_arithmetic",
- defaultValue = "true",
- category = "incompatible changes",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- help = "If set to true, arithmetic operations throw an error in case of overflow/underflow."
- )
- public boolean incompatibleCheckedArithmetic;
-
- @Option(
- name = "incompatible_comprehension_variables_do_not_leak",
- defaultValue = "true",
- category = "incompatible changes",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- help =
- "If set to true, loop variables in a comprehension shadow any existing variable by "
- + "the same name. If the existing variable was declared in the same scope that "
- + "contains the comprehension, then it also becomes inaccessible after the "
- + " comprehension executes."
- )
- public boolean incompatibleComprehensionVariablesDoNotLeak;
-
- @Option(
name = "incompatible_depset_union",
defaultValue = "false",
category = "incompatible changes",
@@ -126,17 +100,6 @@
public boolean incompatibleDepsetIsNotIterable;
@Option(
- name = "incompatible_dict_literal_has_no_duplicates",
- defaultValue = "true",
- category = "incompatible changes",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- help = "If set to true, the dictionary literal syntax doesn't allow duplicated keys."
- )
- public boolean incompatibleDictLiteralHasNoDuplicates;
-
- @Option(
name = "incompatible_disable_glob_tracking",
defaultValue = "false",
category = "incompatible changes",
@@ -159,17 +122,6 @@
public boolean incompatibleDisallowDictPlus;
@Option(
- name = "incompatible_disallow_keyword_only_args",
- defaultValue = "true",
- category = "incompatible changes",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- help = "If set to true, disables the keyword-only argument syntax in function definition."
- )
- public boolean incompatibleDisallowKeywordOnlyArgs;
-
- @Option(
name = "incompatible_disallow_toplevel_if_statement",
defaultValue = "true",
category = "incompatible changes",
@@ -259,14 +211,10 @@
return SkylarkSemantics.builder()
// <== Add new options here in alphabetic order ==>
.incompatibleBzlDisallowLoadAfterStatement(incompatibleBzlDisallowLoadAfterStatement)
- .incompatibleCheckedArithmetic(incompatibleCheckedArithmetic)
- .incompatibleComprehensionVariablesDoNotLeak(incompatibleComprehensionVariablesDoNotLeak)
.incompatibleDepsetIsNotIterable(incompatibleDepsetIsNotIterable)
.incompatibleDepsetUnion(incompatibleDepsetUnion)
- .incompatibleDictLiteralHasNoDuplicates(incompatibleDictLiteralHasNoDuplicates)
.incompatibleDisableGlobTracking(incompatibleDisableGlobTracking)
.incompatibleDisallowDictPlus(incompatibleDisallowDictPlus)
- .incompatibleDisallowKeywordOnlyArgs(incompatibleDisallowKeywordOnlyArgs)
.incompatibleDisallowToplevelIfStatement(incompatibleDisallowToplevelIfStatement)
.incompatibleDisallowUncalledSetConstructor(incompatibleDisallowUncalledSetConstructor)
.incompatibleLoadArgumentIsLabel(incompatibleLoadArgumentIsLabel)
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java b/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java
index 7bdac4d..9f53513 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/AbstractComprehension.java
@@ -279,10 +279,6 @@
evalStep(env, collector, 0);
Object result = collector.getResult(env);
- if (!env.getSemantics().incompatibleComprehensionVariablesDoNotLeak()) {
- return result;
- }
-
// Undefine loop variables (remove them from the environment).
// This code is useful for the transition, to make sure no one relies on the old behavior
// (where loop variables were leaking).
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java
index d898558..b0c82c5 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java
@@ -201,7 +201,7 @@
return pipe(lhs, rhs, env, location);
case MINUS:
- return minus(lhs, rhs, env, location);
+ return minus(lhs, rhs, location);
case MULT:
return mult(lhs, rhs, env, location);
@@ -270,11 +270,7 @@
throws EvalException {
// int + int
if (lval instanceof Integer && rval instanceof Integer) {
- if (env.getSemantics().incompatibleCheckedArithmetic()) {
- return Math.addExact((Integer) lval, (Integer) rval);
- } else {
- return ((Integer) lval).intValue() + ((Integer) rval).intValue();
- }
+ return Math.addExact((Integer) lval, (Integer) rval);
}
// string + string
@@ -358,14 +354,9 @@
}
/** Implements Operator.MINUS. */
- private static Object minus(Object lval, Object rval, Environment env, Location location)
- throws EvalException {
+ private static Object minus(Object lval, Object rval, Location location) throws EvalException {
if (lval instanceof Integer && rval instanceof Integer) {
- if (env.getSemantics().incompatibleCheckedArithmetic()) {
- return Math.subtractExact((Integer) lval, (Integer) rval);
- } else {
- return ((Integer) lval).intValue() - ((Integer) rval).intValue();
- }
+ return Math.subtractExact((Integer) lval, (Integer) rval);
}
throw typeException(lval, rval, Operator.MINUS, location);
}
@@ -386,11 +377,7 @@
if (number != null) {
if (otherFactor instanceof Integer) {
- if (env.getSemantics().incompatibleCheckedArithmetic()) {
- return Math.multiplyExact(number, (Integer) otherFactor);
- } else {
- return number * ((Integer) otherFactor);
- }
+ return Math.multiplyExact(number, (Integer) otherFactor);
} else if (otherFactor instanceof String) {
// Similar to Python, a factor < 1 leads to an empty string.
return Strings.repeat((String) otherFactor, Math.max(0, number));
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/DictionaryLiteral.java b/src/main/java/com/google/devtools/build/lib/syntax/DictionaryLiteral.java
index 815c7bd..79a1bf1 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/DictionaryLiteral.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/DictionaryLiteral.java
@@ -73,7 +73,7 @@
for (DictionaryEntryLiteral entry : entries) {
Object key = entry.key.eval(env);
Object val = entry.value.eval(env);
- if (env.getSemantics().incompatibleDictLiteralHasNoDuplicates() && dict.containsKey(key)) {
+ if (dict.containsKey(key)) {
throw new EvalException(
loc, "Duplicated key " + Printer.repr(key) + " when creating dictionary");
}
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
index 9a1ed7a..a13a9fc 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
@@ -94,13 +94,10 @@
}
}
+ // TODO(laurentlb): Could be moved to the Parser or the ValidationEnvironment?
FunctionSignature sig = node.getSignature().getSignature();
- if (env.getSemantics().incompatibleDisallowKeywordOnlyArgs()
- && sig.getShape().getMandatoryNamedOnly() > 0) {
- throw new EvalException(
- node.getLocation(),
- "Keyword-only argument is forbidden. You can temporarily disable this "
- + "error using the flag --incompatible_disallow_keyword_only_args=false");
+ if (sig.getShape().getMandatoryNamedOnly() > 0) {
+ throw new EvalException(node.getLocation(), "Keyword-only argument is forbidden.");
}
env.update(
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 c816cd6..ccdef1e 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
@@ -40,18 +40,13 @@
// <== Add new options here in alphabetic order ==>
public abstract boolean incompatibleBzlDisallowLoadAfterStatement();
- public abstract boolean incompatibleCheckedArithmetic();
- public abstract boolean incompatibleComprehensionVariablesDoNotLeak();
public abstract boolean incompatibleDepsetIsNotIterable();
public abstract boolean incompatibleDepsetUnion();
- public abstract boolean incompatibleDictLiteralHasNoDuplicates();
-
public abstract boolean incompatibleDisableGlobTracking();
public abstract boolean incompatibleDisallowDictPlus();
- public abstract boolean incompatibleDisallowKeywordOnlyArgs();
public abstract boolean incompatibleDisallowToplevelIfStatement();
public abstract boolean incompatibleDisallowUncalledSetConstructor();
public abstract boolean incompatibleLoadArgumentIsLabel();
@@ -76,14 +71,10 @@
builder()
// <== Add new options here in alphabetic order ==>
.incompatibleBzlDisallowLoadAfterStatement(false)
- .incompatibleCheckedArithmetic(true)
- .incompatibleComprehensionVariablesDoNotLeak(true)
.incompatibleDepsetIsNotIterable(false)
.incompatibleDepsetUnion(false)
- .incompatibleDictLiteralHasNoDuplicates(true)
.incompatibleDisableGlobTracking(false)
.incompatibleDisallowDictPlus(false)
- .incompatibleDisallowKeywordOnlyArgs(true)
.incompatibleDisallowToplevelIfStatement(true)
.incompatibleDisallowUncalledSetConstructor(true)
.incompatibleLoadArgumentIsLabel(true)
@@ -99,18 +90,13 @@
// <== Add new options here in alphabetic order ==>
public abstract Builder incompatibleBzlDisallowLoadAfterStatement(boolean value);
- public abstract Builder incompatibleCheckedArithmetic(boolean value);
- public abstract Builder incompatibleComprehensionVariablesDoNotLeak(boolean value);
public abstract Builder incompatibleDepsetIsNotIterable(boolean value);
public abstract Builder incompatibleDepsetUnion(boolean value);
- public abstract Builder incompatibleDictLiteralHasNoDuplicates(boolean value);
-
public abstract Builder incompatibleDisableGlobTracking(boolean value);
public abstract Builder incompatibleDisallowDictPlus(boolean value);
- public abstract Builder incompatibleDisallowKeywordOnlyArgs(boolean value);
public abstract Builder incompatibleDisallowToplevelIfStatement(boolean value);
public abstract Builder incompatibleDisallowUncalledSetConstructor(boolean value);
public abstract Builder incompatibleLoadArgumentIsLabel(boolean value);
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/UnaryOperatorExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/UnaryOperatorExpression.java
index f676434..824333a 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/UnaryOperatorExpression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/UnaryOperatorExpression.java
@@ -60,7 +60,6 @@
private static Object evaluate(
UnaryOperator operator,
Object value,
- Environment env,
Location loc)
throws EvalException, InterruptedException {
switch (operator) {
@@ -74,15 +73,11 @@
String.format(
"unsupported operand type for -: '%s'", EvalUtils.getDataTypeName(value)));
}
- if (env.getSemantics().incompatibleCheckedArithmetic()) {
- try {
- return Math.negateExact((Integer) value);
- } catch (ArithmeticException e) {
- // Fails for -MIN_INT.
- throw new EvalException(loc, e.getMessage());
- }
- } else {
- return -((Integer) value);
+ try {
+ return Math.negateExact((Integer) value);
+ } catch (ArithmeticException e) {
+ // Fails for -MIN_INT.
+ throw new EvalException(loc, e.getMessage());
}
default:
@@ -92,7 +87,7 @@
@Override
Object doEval(Environment env) throws EvalException, InterruptedException {
- return evaluate(operator, operand.eval(env), env, getLocation());
+ return evaluate(operator, operand.eval(env), getLocation());
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java b/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java
index 38a4781..f7aba2c 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java
@@ -143,13 +143,9 @@
@Override
public void visit(AbstractComprehension node) {
- if (semantics.incompatibleComprehensionVariablesDoNotLeak()) {
- openBlock();
- super.visit(node);
- closeBlock();
- } else {
- super.visit(node);
- }
+ openBlock();
+ super.visit(node);
+ closeBlock();
}
@Override
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
index 339f060..276a1c2 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
@@ -120,14 +120,10 @@
return parseOptions(
// <== Add new options here in alphabetic order ==>
"--incompatible_bzl_disallow_load_after_statement=" + rand.nextBoolean(),
- "--incompatible_checked_arithmetic=" + rand.nextBoolean(),
- "--incompatible_comprehension_variables_do_not_leak=" + rand.nextBoolean(),
"--incompatible_depset_is_not_iterable=" + rand.nextBoolean(),
"--incompatible_depset_union=" + rand.nextBoolean(),
- "--incompatible_dict_literal_has_no_duplicates=" + rand.nextBoolean(),
"--incompatible_disable_glob_tracking=" + rand.nextBoolean(),
"--incompatible_disallow_dict_plus=" + rand.nextBoolean(),
- "--incompatible_disallow_keyword_only_args=" + rand.nextBoolean(),
"--incompatible_disallow_toplevel_if_statement=" + rand.nextBoolean(),
"--incompatible_disallow_uncalled_set_constructor=" + rand.nextBoolean(),
"--incompatible_load_argument_is_label=" + rand.nextBoolean(),
@@ -145,14 +141,10 @@
return SkylarkSemantics.builder()
// <== Add new options here in alphabetic order ==>
.incompatibleBzlDisallowLoadAfterStatement(rand.nextBoolean())
- .incompatibleCheckedArithmetic(rand.nextBoolean())
- .incompatibleComprehensionVariablesDoNotLeak(rand.nextBoolean())
.incompatibleDepsetIsNotIterable(rand.nextBoolean())
.incompatibleDepsetUnion(rand.nextBoolean())
- .incompatibleDictLiteralHasNoDuplicates(rand.nextBoolean())
.incompatibleDisableGlobTracking(rand.nextBoolean())
.incompatibleDisallowDictPlus(rand.nextBoolean())
- .incompatibleDisallowKeywordOnlyArgs(rand.nextBoolean())
.incompatibleDisallowToplevelIfStatement(rand.nextBoolean())
.incompatibleDisallowUncalledSetConstructor(rand.nextBoolean())
.incompatibleLoadArgumentIsLabel(rand.nextBoolean())
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
index 5ac5a2f..5ecd0e8 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
@@ -224,7 +224,7 @@
@Test
public void testCheckedArithmetic() throws Exception {
- new SkylarkTest("--incompatible_checked_arithmetic=true")
+ new SkylarkTest()
.testIfErrorContains("integer overflow", "2000000000 + 2000000000")
.testIfErrorContains("integer overflow", "1234567890 * 987654321")
.testIfErrorContains("integer overflow", "- 2000000000 - 2000000000")
@@ -384,18 +384,12 @@
@Test
public void testDictWithDuplicatedKey() throws Exception {
- new SkylarkTest("--incompatible_dict_literal_has_no_duplicates=true")
+ new SkylarkTest()
.testIfErrorContains(
"Duplicated key \"str\" when creating dictionary", "{'str': 1, 'x': 2, 'str': 3}");
}
@Test
- public void testDictAllowDuplicatedKey() throws Exception {
- new SkylarkTest("--incompatible_dict_literal_has_no_duplicates=false")
- .testStatement("{'str': 1, 'x': 2, 'str': 3}", ImmutableMap.of("str", 3, "x", 2));
- }
-
- @Test
public void testRecursiveTupleDestructuring() throws Exception {
newTest()
.setUp("((a, b), (c, d)) = [(1, 2), (3, 4)]")
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 76aebfb..ff8dddc 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
@@ -300,13 +300,11 @@
@Test
public void testKeywordOnlyIsForbidden() throws Exception {
- env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_keyword_only_args=true");
checkEvalErrorContains("forbidden", "def foo(a, b, *, c): return a + b + c");
}
@Test
public void testParamAfterStarArgs() throws Exception {
- env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_keyword_only_args=true");
checkEvalErrorContains("forbidden", "def foo(a, *b, c): return a");
}
@@ -372,8 +370,7 @@
}
@Test
- public void testIncompatibleStarParam() throws Exception {
- env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_keyword_only_args=true");
+ public void testStarParam() throws Exception {
eval("def f(name, value = '1', optional = '2', *rest):",
" r = name + value + optional + '|'",
" for x in rest: r += x",
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 c234a92..3b7bba3 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
@@ -1635,8 +1635,6 @@
@Test
public void testListComprehensionsDoNotLeakVariables() throws Exception {
- env =
- newEnvironmentWithSkylarkOptions("--incompatible_comprehension_variables_do_not_leak=true");
checkEvalErrorContains(
"name 'a' is not defined",
"def foo():",
@@ -1648,22 +1646,11 @@
@Test
public void testListComprehensionsShadowGlobalVariable() throws Exception {
- env =
- newEnvironmentWithSkylarkOptions("--incompatible_comprehension_variables_do_not_leak=true");
eval("a = 18", "def foo():", " b = [a for a in range(3)]", " return a", "x = foo()");
assertThat(lookup("x")).isEqualTo(18);
}
@Test
- public void testListComprehensionsLeakVariables() throws Exception {
- env =
- newEnvironmentWithSkylarkOptions(
- "--incompatible_comprehension_variables_do_not_leak=false");
- eval("def foo():", " a = 10", " b = [a for a in range(3)]", " return a", "x = foo()");
- assertThat(lookup("x")).isEqualTo(2);
- }
-
- @Test
public void testLoadStatementWithAbsolutePath() throws Exception {
env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label");
checkEvalErrorContains(