Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
simkoc opened this issue Nov 16, 2020 · 0 comments
Open

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

simkoc opened this issue Nov 16, 2020 · 0 comments

Comments

@simkoc
Copy link

simkoc commented Nov 16, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant