Skip to content

Commit b779341

Browse files
authored
Merge pull request #16885 from github/tausbn/python-fix-bad-join-in-function-resolution-type-tracker
Python: Fix bad join in function resolution
2 parents f9536e9 + e5a15f3 commit b779341

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

python/ql/lib/semmle/python/frameworks/internal/PoorMansFunctionResolution.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ private import semmle.python.dataflow.new.DataFlow
2222
/**
2323
* Gets the last decorator call for the function `func`, if `func` has decorators.
2424
*/
25-
private Expr lastDecoratorCall(Function func) {
26-
result = func.getDefinition().(FunctionExpr).getADecoratorCall() and
27-
not exists(Call other_decorator | other_decorator.getArg(0) = result)
25+
pragma[nomagic]
26+
private DataFlow::TypeTrackingNode lastDecoratorCall(Function func) {
27+
result.asExpr() = func.getDefinition().(FunctionExpr).getADecoratorCall() and
28+
not exists(Call other_decorator | other_decorator.getArg(0) = result.asExpr())
2829
}
2930

3031
/**
@@ -56,7 +57,7 @@ private DataFlow::TypeTrackingNode poorMansFunctionTracker(DataFlow::TypeTracker
5657
//
5758
// Note that this means that we blindly ignore what the decorator actually does to
5859
// the function, which seems like an OK tradeoff.
59-
result.asExpr() = lastDecoratorCall(func)
60+
result = pragma[only_bind_out](lastDecoratorCall(func))
6061
)
6162
or
6263
exists(DataFlow::TypeTracker t2 | result = poorMansFunctionTracker(t2, func).track(t2, t))

0 commit comments

Comments
 (0)