Require parens around tuple with trailing comma.
RELNOTES[INC]:
Tuples that end with a trailing comma must now be inside parens,
e.g. (1,) instead of 1,
--
PiperOrigin-RevId: 144690953
MOS_MIGRATED_REVID=144690953
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 c527fd2..43f6bcf 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
@@ -555,8 +555,19 @@
}
@Test
- public void testTupleWithoutParensWithTrailingComma() throws Exception {
- ListLiteral tuple = (ListLiteral) parseExpression("0, 1, 2, 3,");
+ public void testTupleWithTrailingComma() throws Exception {
+ setFailFast(false);
+
+ // Unlike Python, we require parens here.
+ parseExpression("0, 1, 2, 3,");
+ assertContainsError("Trailing comma");
+ clearEvents();
+
+ parseExpression("1 + 2,");
+ assertContainsError("Trailing comma");
+ clearEvents();
+
+ ListLiteral tuple = (ListLiteral) parseExpression("(0, 1, 2, 3,)");
assertTrue(tuple.isTuple());
assertThat(tuple.getElements()).hasSize(4);
assertTrue(tuple.isTuple());