Ruby: support Proc.new alongside 'proc' and 'lambda'

This commit is contained in:
Asger F
2023-06-29 11:16:29 +02:00
parent 194fe85442
commit f232669ea5
2 changed files with 6 additions and 2 deletions

View File

@@ -1333,7 +1333,12 @@ 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", "proc"]
(
mc.getExpr().getMethodName() = ["lambda", "proc"]
or
mc.getExpr().getMethodName() = "new" and
mc.getReceiver().getExpr().(ConstantReadAccess).getAQualifiedName() = "Proc"
)
)
)
}

View File

@@ -1,3 +1,2 @@
failures
testFailures
| explicit-proc.rb:10:7:10:78 | # $ reachableFromSource=Member[Foo].Method[bar].Argument[0].Parameter[0] | Missing result:reachableFromSource=Member[Foo].Method[bar].Argument[0].Parameter[0] |