Fix Skylark parsing of call expressions.
This allows more complex expressions to be called, not just identifiers.
For example, "x[0]()" is not a syntax error anymore.
RELNOTES: None
PiperOrigin-RevId: 165157981
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 c616b2a..a9a9e4c 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
@@ -174,10 +174,13 @@
@Test
public void testFuncallExpr() throws Exception {
- FuncallExpression e = (FuncallExpression) parseExpression("foo(1, 2, bar=wiz)");
+ FuncallExpression e = (FuncallExpression) parseExpression("foo[0](1, 2, bar=wiz)");
- Identifier ident = (Identifier) e.getFunction();
- assertThat(ident.getName()).isEqualTo("foo");
+ IndexExpression function = (IndexExpression) e.getFunction();
+ Identifier functionList = (Identifier) function.getObject();
+ assertThat(functionList.getName()).isEqualTo("foo");
+ IntegerLiteral listIndex = (IntegerLiteral) function.getKey();
+ assertThat(listIndex.getValue()).isEqualTo(0);
assertThat(e.getArguments()).hasSize(3);
assertThat(e.getNumPositionalArguments()).isEqualTo(2);