Repository: joernio/joern (scala)

Issue:
jssrc: wrong argument indizes in push calls within desugared array literals
```
joern> workspace.reset ; importCode.jssrc.fromString("""[0]""")
...
joern> cpg.literal.size
val res1: Int = 1
joern> cpg.literal.head.argumentIndex
val res4: Int = 2
joern> cpg.literal.expressionUp.code.head
val res5: String = "_tmp_0.push(0)"
joern> cpg.literal.inCall.argument.isIdentifier.argumentIndex.head
val res15: Int = 1
```

Pull request description:
Fixes: https://github.com/joernio/joern/issues/2049

Patch:
diff --git a/joern-cli/frontends/jssrc2cpg/src/main/scala/io/joern/jssrc2cpg/astcreation/AstForExpressionsCreator.scala b/joern-cli/frontends/jssrc2cpg/src/main/scala/io/joern/jssrc2cpg/astcreation/AstForExpressionsCreator.scala
index 9d0e8e5666ab..e58eb1e28b6c 100644
--- a/joern-cli/frontends/jssrc2cpg/src/main/scala/io/joern/jssrc2cpg/astcreation/AstForExpressionsCreator.scala
+++ b/joern-cli/frontends/jssrc2cpg/src/main/scala/io/joern/jssrc2cpg/astcreation/AstForExpressionsCreator.scala
@@ -386,8 +386,14 @@ trait AstForExpressionsCreator { this: AstCreator =>
           val receiverNode = createFieldAccessCallAst(baseNode, memberNode, elementLineNumber, elementColumnNumber)
           val thisPushNode = createIdentifierNode(tmpName, elementNodeInfo)
 
-          val argAsts = List(Ast(thisPushNode), elementNode)
-          Some(createCallAst(pushCallNode, argAsts, Some(receiverNode)))
+          Some(
+            createCallAst(
+              pushCallNode,
+              List(elementNode),
+              receiver = Some(receiverNode),
+              base = Some(Ast(thisPushNode))
+            )
+          )
         case _ => None // skip
       }
 


Test patch:
diff --git a/joern-cli/frontends/jssrc2cpg/src/test/scala/io/joern/jssrc2cpg/passes/ast/SimpleAstCreationPassTest.scala b/joern-cli/frontends/jssrc2cpg/src/test/scala/io/joern/jssrc2cpg/passes/ast/SimpleAstCreationPassTest.scala
index 020dcea10eb6..e4accd95dd27 100644
--- a/joern-cli/frontends/jssrc2cpg/src/test/scala/io/joern/jssrc2cpg/passes/ast/SimpleAstCreationPassTest.scala
+++ b/joern-cli/frontends/jssrc2cpg/src/test/scala/io/joern/jssrc2cpg/passes/ast/SimpleAstCreationPassTest.scala
@@ -1527,19 +1527,15 @@ class SimpleAstCreationPassTest extends AbstractPassTest {
 
     val pushCallReceiverBase = pushCallReceiver.argument(1).asInstanceOf[Identifier]
     pushCallReceiverBase.name shouldBe "_tmp_0"
-    pushCallReceiverBase.argumentIndex shouldBe 1
 
     val pushCallReceiverMember = pushCallReceiver.argument(2).asInstanceOf[FieldIdentifier]
     pushCallReceiverMember.canonicalName shouldBe "push"
-    pushCallReceiverMember.argumentIndex shouldBe 2
 
-    val pushCallThis = pushCall.argument(1).asInstanceOf[Identifier]
+    val pushCallThis = pushCall.argument(0).asInstanceOf[Identifier]
     pushCallThis.name shouldBe "_tmp_0"
-    pushCallThis.argumentIndex shouldBe 1
 
-    val pushCallArg = pushCall.argument(2).asInstanceOf[Literal]
+    val pushCallArg = pushCall.argument(1).asInstanceOf[Literal]
     pushCallArg.code shouldBe element.toString
-    pushCallArg.argumentIndex shouldBe 2
   }
 
 }