Skip to content

usage of call.argument without any parameter leads to compiler error #1023

Description

@simkoc
cpg.call.codeExact("...").head match {
     case (call : nodes.Call) :: Nil =>
          println(call.argument.l.length)
}

leads to compiler error:

missing argument list for method argument in class CallMethods
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] You can make this conversion explicit by writing `argument _` or `argument(_)` instead of `argument`.

When applying the suggested fix:

cpg.call.codeExact("...").head match {
     case (call : nodes.Call) :: Nil =>
          println(call.argument(_).l.length)
}

I get the compiler error:

missing parameter type for expanded function ((<x$1: error>) => call.argument(x$1).l.length.shouldBe(1))
[error]           println(call.argument(_).l.length)
[error]  

I was expecting to simply print the amount of arguments connected to that call node.

Current work-around:

cpg.call.codeExact("...").head match {
     case (call : nodes.Call) :: Nil =>
          println(call.out(EdgeTypes.ARGUMENT).asScala.toList.length)
}

I am using cpg version: 1.2.25

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions