mirror of
https://github.com/github/codeql.git
synced 2026-02-07 18:51:06 +01:00
fix the arity of predicate aliases
This commit is contained in:
committed by
GitHub
parent
8dc3948221
commit
bd86ffb35b
@@ -154,7 +154,14 @@ class Predicate extends TPredicate, AstNode {
|
||||
/**
|
||||
* Gets the number of parameters.
|
||||
*/
|
||||
int getArity() { result = count(getParameter(_)) }
|
||||
int getArity() {
|
||||
not this.(ClasslessPredicate).getAlias() instanceof PredicateExpr and
|
||||
result = count(getParameter(_))
|
||||
or
|
||||
exists(PredicateExpr alias | alias = this.(ClasslessPredicate).getAlias() |
|
||||
result = alias.getArity()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the return type (if any) of the predicate.
|
||||
|
||||
@@ -240,6 +240,7 @@ module PredConsistency {
|
||||
query predicate noResolveCall(Call c) {
|
||||
not resolveCall(c, _) and
|
||||
not c instanceof NoneCall and
|
||||
not c instanceof AnyCall and
|
||||
not c.getLocation().getFile().getAbsolutePath().regexpMatch(".*/(test|examples)/.*")
|
||||
}
|
||||
|
||||
|
||||
@@ -15,3 +15,19 @@ class Sub extends Foo {
|
||||
}
|
||||
|
||||
query predicate test2() { any(Foo f).bar() }
|
||||
|
||||
module Aliases {
|
||||
predicate myThing2(int i, int j) { i = 2 and j = 3 }
|
||||
|
||||
predicate myThing0() { any() }
|
||||
|
||||
predicate alias0 = myThing0/0;
|
||||
|
||||
predicate alias2 = myThing2/2;
|
||||
|
||||
query predicate test3() {
|
||||
alias2(3, 4) // doesn't work.
|
||||
or
|
||||
alias0() // <- works
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,3 +2,7 @@
|
||||
| Foo.qll:10:21:10:25 | PredicateCall | Foo.qll:8:3:8:28 | ClassPredicate |
|
||||
| Foo.qll:14:30:14:40 | MemberCall | Foo.qll:10:3:10:27 | ClassPredicate |
|
||||
| Foo.qll:17:27:17:42 | MemberCall | Foo.qll:8:3:8:28 | ClassPredicate |
|
||||
| Foo.qll:29:5:29:16 | PredicateCall | Foo.qll:20:3:20:54 | myThing2 |
|
||||
| Foo.qll:29:5:29:16 | PredicateCall | Foo.qll:26:3:26:32 | alias2 |
|
||||
| Foo.qll:31:5:31:12 | PredicateCall | Foo.qll:22:3:22:32 | myThing0 |
|
||||
| Foo.qll:31:5:31:12 | PredicateCall | Foo.qll:24:3:24:32 | alias0 |
|
||||
|
||||
Reference in New Issue
Block a user