Ruby: use lambdaCreation and handle "proc" in there

This commit is contained in:
Asger F
2022-11-07 09:14:55 +01:00
parent 4ae90e35d5
commit 8b85744d3e
2 changed files with 4 additions and 6 deletions

View File

@@ -1300,7 +1300,7 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
creation.asExpr() =
any(CfgNodes::ExprNodes::MethodCallCfgNode mc |
c.asCallable() = mc.getBlock().getExpr() and
mc.getExpr().getMethodName() = "lambda"
mc.getExpr().getMethodName() = ["lambda", "proc"]
)
)
}

View File

@@ -73,11 +73,9 @@ class Node extends TNode {
CallableNode asCallable() {
result = this
or
exists(CallNode call |
call.getReceiver().asExpr().getExpr() instanceof SelfVariableAccess and
call.getMethodName() = ["proc", "lambda"] and
call.getBlock() = result and
this = call
exists(DataFlowCallable c |
lambdaCreation(this, _, c) and
result.asCallableAstNode() = c.asCallable()
)
}
}